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 java.util.Set;
22
23 import org.apache.maven.artifact.Artifact;
24 import org.apache.maven.plugin.AbstractMojo;
25 import org.apache.maven.plugin.MojoExecutionException;
26 import org.apache.maven.plugins.annotations.LifecyclePhase;
27 import org.apache.maven.plugins.annotations.Mojo;
28 import org.apache.maven.plugins.annotations.Parameter;
29 import org.apache.maven.plugins.annotations.ResolutionScope;
30 import org.apache.maven.project.MavenProject;
31
32
33
34
35
36
37
38
39
40
41 @Mojo(
42 name = "properties",
43 requiresDependencyResolution = ResolutionScope.TEST,
44 defaultPhase = LifecyclePhase.INITIALIZE,
45 threadSafe = true)
46
47 public class PropertiesMojo extends AbstractMojo {
48
49
50
51
52 @Parameter(defaultValue = "${project}", readonly = true, required = true)
53 private MavenProject project;
54
55
56
57
58
59
60 @Parameter(property = "mdep.skip", defaultValue = "false")
61 private boolean skip;
62
63
64
65
66
67
68 @Override
69 public void execute() throws MojoExecutionException {
70 if (isSkip()) {
71 getLog().info("Skipping plugin execution");
72 return;
73 }
74
75 Set<Artifact> artifacts = project.getArtifacts();
76
77 for (Artifact artifact : artifacts) {
78 project.getProperties()
79 .setProperty(
80 artifact.getDependencyConflictId(),
81 artifact.getFile().getAbsolutePath());
82 }
83 }
84
85
86
87
88 public boolean isSkip() {
89 return skip;
90 }
91 }