1 package org.apache.maven.plugins.dependency.fromDependencies;
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.MojoExecutionException;
24 import org.apache.maven.plugins.dependency.utils.DependencyStatusSets;
25 import org.apache.maven.plugins.dependency.utils.DependencyUtil;
26 import org.apache.maven.plugins.dependency.utils.filters.MarkerFileFilter;
27 import org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler;
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.File;
35
36
37
38
39
40
41
42
43 @Mojo( name = "unpack-dependencies", requiresDependencyResolution = ResolutionScope.TEST, defaultPhase = LifecyclePhase.PROCESS_SOURCES, threadSafe = true )
44
45 public class UnpackDependenciesMojo
46 extends AbstractFromDependenciesMojo
47 {
48
49
50
51
52
53
54
55 @Parameter( property = "mdep.unpack.includes" )
56 private String includes;
57
58
59
60
61
62
63
64
65 @Parameter( property = "mdep.unpack.excludes" )
66 private String excludes;
67
68
69
70
71
72
73 @Parameter( property = "mdep.unpack.encoding" )
74 private String encoding;
75
76
77
78
79
80
81
82
83
84 @Override
85 protected void doExecute()
86 throws MojoExecutionException
87 {
88 DependencyStatusSets dss = getDependencySets( this.failOnMissingClassifierArtifact );
89
90 for ( Artifact artifact : dss.getResolvedDependencies() )
91 {
92 File destDir;
93 destDir = DependencyUtil.getFormattedOutputDirectory( useSubDirectoryPerScope, useSubDirectoryPerType,
94 useSubDirectoryPerArtifact, useRepositoryLayout,
95 stripVersion, outputDirectory, artifact );
96 unpack( artifact, destDir, getIncludes(), getExcludes(), getEncoding() );
97 DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler( artifact, this.markersDirectory );
98 handler.setMarker();
99 }
100
101 for ( Artifact artifact : dss.getSkippedDependencies() )
102 {
103 getLog().info( artifact.getId() + " already exists in destination." );
104 }
105 }
106
107 @Override
108 protected ArtifactsFilter getMarkedArtifactFilter()
109 {
110 return new MarkerFileFilter( this.overWriteReleases, this.overWriteSnapshots, this.overWriteIfNewer,
111 new DefaultFileMarkerHandler( this.markersDirectory ) );
112 }
113
114
115
116
117 public String getExcludes()
118 {
119 return DependencyUtil.cleanToBeTokenizedString( this.excludes );
120 }
121
122
123
124
125 public void setExcludes( String excludes )
126 {
127 this.excludes = excludes;
128 }
129
130
131
132
133 public String getIncludes()
134 {
135 return DependencyUtil.cleanToBeTokenizedString( this.includes );
136 }
137
138
139
140
141 public void setIncludes( String includes )
142 {
143 this.includes = includes;
144 }
145
146
147
148
149
150 public void setEncoding( String encoding )
151 {
152 this.encoding = encoding;
153 }
154
155
156
157
158
159 public String getEncoding()
160 {
161 return this.encoding;
162 }
163 }