1 package org.apache.maven.plugin.coreit;
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.artifact.factory.ArtifactFactory;
24 import org.apache.maven.artifact.repository.ArtifactRepository;
25 import org.apache.maven.model.Dependency;
26 import org.apache.maven.plugin.MojoExecutionException;
27 import org.apache.maven.project.MavenProject;
28
29 import java.io.File;
30 import java.util.List;
31 import java.util.Properties;
32
33
34
35
36
37
38
39
40 public class BuildRemotePomMojo
41 extends AbstractPomMojo
42 {
43
44
45
46
47
48
49 private File propertiesFile;
50
51
52
53
54
55
56
57
58 private ArtifactRepository localRepository;
59
60
61
62
63
64
65
66
67 private List remoteRepositories;
68
69
70
71
72
73
74 private ArtifactFactory factory;
75
76
77
78
79
80
81 private Dependency[] dependencies;
82
83
84
85
86
87
88 public void execute()
89 throws MojoExecutionException
90 {
91 Properties props = new Properties();
92
93 getLog().info( "[MAVEN-CORE-IT-LOG] Building remote POMs" );
94
95 if ( dependencies != null )
96 {
97 for ( Dependency dependency : dependencies )
98 {
99 Artifact artifact =
100 factory.createArtifactWithClassifier( dependency.getGroupId(), dependency.getArtifactId(),
101 dependency.getVersion(), dependency.getType(),
102 dependency.getClassifier() );
103
104 String id = artifact.getId();
105
106 getLog().info( "[MAVEN-CORE-IT-LOG] Building " + id );
107
108 try
109 {
110 MavenProject project = builder.buildFromRepository( artifact, remoteRepositories, localRepository );
111
112 dump( props, id + ".", project );
113 }
114 catch ( Exception e )
115 {
116 getLog().warn( "Failed to build remote POM for " + artifact.getId(), e );
117 }
118
119 put( props, id + ".file", artifact.getFile() );
120 put( props, id + ".version", artifact.getVersion() );
121 }
122 }
123
124 store( props, propertiesFile );
125 }
126
127 }