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 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,
43 defaultPhase = LifecyclePhase.INITIALIZE, threadSafe = true )
44 public class PropertiesMojo
45 extends AbstractMojo
46 {
47
48
49
50
51 @Parameter( defaultValue = "${project}", readonly = true, required = true )
52 protected 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 public void execute()
68 throws MojoExecutionException
69 {
70 if ( isSkip() )
71 {
72 getLog().info( "Skipping plugin execution" );
73 return;
74 }
75
76 @SuppressWarnings( "unchecked" ) Set<Artifact> artifacts = getProject().getArtifacts();
77
78 for ( Artifact artifact : artifacts )
79 {
80 project.getProperties().setProperty( artifact.getDependencyConflictId(),
81 artifact.getFile().getAbsolutePath() );
82 }
83 }
84
85 public MavenProject getProject()
86 {
87 return project;
88 }
89
90 public boolean isSkip()
91 {
92 return skip;
93 }
94
95 public void setSkip( boolean skip )
96 {
97 this.skip = skip;
98 }
99 }