1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.dependency;
20
21 import javax.inject.Inject;
22
23 import java.util.Set;
24
25 import org.apache.maven.artifact.Artifact;
26 import org.apache.maven.plugin.AbstractMojo;
27 import org.apache.maven.plugin.MojoExecutionException;
28 import org.apache.maven.plugins.annotations.LifecyclePhase;
29 import org.apache.maven.plugins.annotations.Mojo;
30 import org.apache.maven.plugins.annotations.Parameter;
31 import org.apache.maven.plugins.annotations.ResolutionScope;
32 import org.apache.maven.project.MavenProject;
33
34
35
36
37
38
39
40
41
42
43 @Mojo(
44 name = "properties",
45 requiresDependencyResolution = ResolutionScope.TEST,
46 defaultPhase = LifecyclePhase.INITIALIZE,
47 threadSafe = true)
48
49 public class PropertiesMojo extends AbstractMojo {
50
51
52
53
54 private final MavenProject project;
55
56 @Inject
57 public PropertiesMojo(MavenProject project) {
58 this.project = project;
59 }
60
61
62
63
64
65
66 @Parameter(property = "mdep.skip", defaultValue = "false")
67 private boolean skip;
68
69
70
71
72
73
74 @Override
75 public void execute() throws MojoExecutionException {
76 if (isSkip()) {
77 getLog().info("Skipping plugin execution");
78 return;
79 }
80
81 Set<Artifact> artifacts = project.getArtifacts();
82
83 for (Artifact artifact : artifacts) {
84 project.getProperties()
85 .setProperty(
86 artifact.getDependencyConflictId(),
87 artifact.getFile().getAbsolutePath());
88 }
89 }
90
91
92
93
94 public boolean isSkip() {
95 return skip;
96 }
97 }