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.concurrent;
20
21 import java.util.Collection;
22 import java.util.Collections;
23 import java.util.List;
24 import java.util.stream.Collectors;
25 import java.util.stream.Stream;
26
27 import org.apache.maven.api.Lifecycle;
28 import org.apache.maven.api.model.Plugin;
29 import org.apache.maven.plugin.descriptor.PluginDescriptor;
30
31 class PluginLifecycle implements Lifecycle {
32 private final org.apache.maven.api.plugin.descriptor.lifecycle.Lifecycle lifecycleOverlay;
33 private final PluginDescriptor pluginDescriptor;
34
35 PluginLifecycle(
36 org.apache.maven.api.plugin.descriptor.lifecycle.Lifecycle lifecycleOverlay,
37 PluginDescriptor pluginDescriptor) {
38 this.lifecycleOverlay = lifecycleOverlay;
39 this.pluginDescriptor = pluginDescriptor;
40 }
41
42 @Override
43 public String id() {
44 return lifecycleOverlay.getId();
45 }
46
47 @Override
48 public Collection<Phase> phases() {
49 return lifecycleOverlay.getPhases().stream()
50 .map(phase -> new Phase() {
51 @Override
52 public String name() {
53 return phase.getId();
54 }
55
56 @Override
57 public List<Plugin> plugins() {
58 return Collections.singletonList(Plugin.newBuilder()
59 .groupId(pluginDescriptor.getGroupId())
60 .artifactId(pluginDescriptor.getArtifactId())
61 .version(pluginDescriptor.getVersion())
62 .configuration(phase.getConfiguration())
63 .executions(phase.getExecutions().stream()
64 .map(exec -> org.apache.maven.api.model.PluginExecution.newBuilder()
65 .goals(exec.getGoals())
66 .configuration(exec.getConfiguration())
67 .build())
68 .collect(Collectors.toList()))
69 .build());
70 }
71
72 @Override
73 public Collection<Link> links() {
74 return Collections.emptyList();
75 }
76
77 @Override
78 public List<Phase> phases() {
79 return Collections.emptyList();
80 }
81
82 @Override
83 public Stream<Phase> allPhases() {
84 return Stream.concat(Stream.of(this), phases().stream().flatMap(Phase::allPhases));
85 }
86 })
87 .collect(Collectors.toList());
88 }
89
90 @Override
91 public Collection<Alias> aliases() {
92 return Collections.emptyList();
93 }
94 }