1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.maven.lifecycle.internal.stub;
17
18 import org.apache.maven.execution.MavenSession;
19 import org.apache.maven.lifecycle.internal.GoalTask;
20 import org.apache.maven.lifecycle.internal.LifecycleTask;
21 import org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator;
22 import org.apache.maven.lifecycle.internal.TaskSegment;
23 import org.apache.maven.plugin.InvalidPluginDescriptorException;
24 import org.apache.maven.plugin.MojoNotFoundException;
25 import org.apache.maven.plugin.PluginDescriptorParsingException;
26 import org.apache.maven.plugin.PluginNotFoundException;
27 import org.apache.maven.plugin.PluginResolutionException;
28 import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException;
29 import org.apache.maven.plugin.version.PluginVersionResolutionException;
30
31 import java.util.ArrayList;
32 import java.util.List;
33
34
35
36
37 public class LifecycleTaskSegmentCalculatorStub
38 extends DefaultLifecycleTaskSegmentCalculator
39 {
40 public static final String clean = "clean";
41
42 public static final String aggr = "aggr";
43
44 public static final String install = "install";
45
46
47 public List<TaskSegment> calculateTaskSegments( MavenSession session, List<String> tasks )
48 throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
49 MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
50 PluginVersionResolutionException
51 {
52 List<TaskSegment> taskSegments = new ArrayList<TaskSegment>( tasks.size() );
53
54 TaskSegment currentSegment = null;
55
56 for ( String task : tasks )
57 {
58 if ( aggr.equals( task ) )
59 {
60 boolean aggregating = true;
61
62 if ( currentSegment == null || currentSegment.isAggregating() != aggregating )
63 {
64 currentSegment = new TaskSegment( aggregating );
65 taskSegments.add( currentSegment );
66 }
67
68 currentSegment.getTasks().add( new GoalTask( task ) );
69 }
70 else
71 {
72
73 if ( currentSegment == null || currentSegment.isAggregating() )
74 {
75 currentSegment = new TaskSegment( false );
76 taskSegments.add( currentSegment );
77 }
78 currentSegment.getTasks().add( new LifecycleTask( task ) );
79 }
80 }
81
82 return taskSegments;
83 }
84
85 public boolean requiresProject( MavenSession session )
86 {
87 return true;
88 }
89 }