1 package org.apache.maven.plugin.dependency;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.artifact.Artifact;
23 import org.apache.maven.plugin.AbstractMojo;
24 import org.apache.maven.plugin.MojoExecutionException;
25 import org.apache.maven.plugins.annotations.Component;
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 import java.util.Set;
33
34
35
36
37
38
39
40
41
42
43 @Mojo( name = "properties", requiresDependencyResolution = ResolutionScope.TEST,
44 defaultPhase = LifecyclePhase.INITIALIZE, threadSafe = true )
45 public class PropertiesMojo
46 extends AbstractMojo
47 {
48
49
50
51
52 @Component
53 protected 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 public void execute()
69 throws MojoExecutionException
70 {
71 if ( isSkip() )
72 {
73 getLog().info( "Skipping plugin execution" );
74 return;
75 }
76
77 @SuppressWarnings( "unchecked" ) Set<Artifact> artifacts = getProject().getArtifacts();
78
79 for ( Artifact artifact : artifacts )
80 {
81 project.getProperties().setProperty( artifact.getDependencyConflictId(),
82 artifact.getFile().getAbsolutePath() );
83 }
84 }
85
86 public MavenProject getProject()
87 {
88 return project;
89 }
90
91 public boolean isSkip()
92 {
93 return skip;
94 }
95
96 public void setSkip( boolean skip )
97 {
98 this.skip = skip;
99 }
100 }