1 | |
package org.apache.maven.plugin.dependency.resolvers; |
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.plugin.MojoExecutionException; |
23 | |
import org.apache.maven.plugin.dependency.AbstractResolveMojo; |
24 | |
import org.apache.maven.plugin.dependency.utils.DependencyStatusSets; |
25 | |
import org.apache.maven.plugin.dependency.utils.DependencyUtil; |
26 | |
import org.apache.maven.plugin.dependency.utils.filters.ResolveFileFilter; |
27 | |
import org.apache.maven.plugin.dependency.utils.markers.SourcesFileMarkerHandler; |
28 | |
import org.apache.maven.plugins.annotations.LifecyclePhase; |
29 | |
import org.apache.maven.plugins.annotations.Mojo; |
30 | |
import org.apache.maven.plugins.annotations.Parameter; |
31 | |
import org.apache.maven.plugins.annotations.ResolutionScope; |
32 | |
import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; |
33 | |
|
34 | |
import java.io.IOException; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
@Mojo( name = "resolve", requiresDependencyResolution = ResolutionScope.TEST, |
44 | |
defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true ) |
45 | 4 | public class ResolveDependenciesMojo |
46 | |
extends AbstractResolveMojo |
47 | |
{ |
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
@Parameter( property = "mdep.outputScope", defaultValue = "true" ) |
55 | |
protected boolean outputScope; |
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
DependencyStatusSets results; |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
public void execute() |
68 | |
throws MojoExecutionException |
69 | |
{ |
70 | |
|
71 | 4 | results = this.getDependencySets( false ); |
72 | |
|
73 | 4 | String output = results.getOutput( outputAbsoluteArtifactFilename, outputScope ); |
74 | |
try |
75 | |
{ |
76 | 4 | if ( outputFile == null ) |
77 | |
{ |
78 | 4 | DependencyUtil.log( output, getLog() ); |
79 | |
} |
80 | |
else |
81 | |
{ |
82 | 0 | DependencyUtil.write( output, outputFile, appendOutput, getLog() ); |
83 | |
} |
84 | |
} |
85 | 0 | catch ( IOException e ) |
86 | |
{ |
87 | 0 | throw new MojoExecutionException( e.getMessage(), e ); |
88 | 4 | } |
89 | 4 | } |
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
public DependencyStatusSets getResults() |
95 | |
{ |
96 | 4 | return this.results; |
97 | |
} |
98 | |
|
99 | |
protected ArtifactsFilter getMarkedArtifactFilter() |
100 | |
{ |
101 | 4 | return new ResolveFileFilter( new SourcesFileMarkerHandler( this.markersDirectory ) ); |
102 | |
} |
103 | |
} |