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