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