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