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