1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.dependency.fromConfiguration;
20
21 import java.io.File;
22 import java.util.Objects;
23
24 import org.apache.maven.artifact.Artifact;
25 import org.apache.maven.artifact.ArtifactUtils;
26 import org.apache.maven.plugins.annotations.Parameter;
27 import org.apache.maven.plugins.dependency.utils.DependencyUtil;
28 import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
29 import org.codehaus.plexus.components.io.filemappers.FileMapper;
30
31
32
33
34
35
36
37 public class ArtifactItem implements DependableCoordinate {
38
39
40
41
42 @Parameter(required = true)
43 private String groupId;
44
45
46
47
48 @Parameter(required = true)
49 private String artifactId;
50
51
52
53
54 @Parameter
55 private String version = null;
56
57
58
59
60
61 @Parameter(required = true)
62 private String type = "jar";
63
64
65
66
67 @Parameter
68 private String classifier;
69
70
71
72
73 @Parameter
74 private File outputDirectory;
75
76
77
78
79 @Parameter
80 private String destFileName;
81
82
83
84
85 private String overWrite;
86
87
88
89
90 @Parameter
91 private String encoding;
92
93
94
95
96 private boolean needsProcessing;
97
98
99
100
101 private Artifact artifact;
102
103
104
105
106 private String includes;
107
108
109
110
111 private String excludes;
112
113
114
115
116
117
118 @Parameter
119 private FileMapper[] fileMappers;
120
121
122
123
124 public ArtifactItem() {
125
126 }
127
128
129
130
131 public ArtifactItem(Artifact artifact) {
132 this.setArtifact(artifact);
133 this.setArtifactId(artifact.getArtifactId());
134 this.setClassifier(artifact.getClassifier());
135 this.setGroupId(artifact.getGroupId());
136 this.setType(artifact.getType());
137 this.setVersion(artifact.getVersion());
138 }
139
140 private String filterEmptyString(String in) {
141 if ("".equals(in)) {
142 return null;
143 }
144 return in;
145 }
146
147
148
149
150 public String getArtifactId() {
151 return artifactId;
152 }
153
154
155
156
157 public void setArtifactId(String theArtifact) {
158 this.artifactId = filterEmptyString(theArtifact);
159 }
160
161
162
163
164 public String getGroupId() {
165 return groupId;
166 }
167
168
169
170
171 public void setGroupId(String groupId) {
172 this.groupId = filterEmptyString(groupId);
173 }
174
175
176
177
178 public String getType() {
179 return type;
180 }
181
182
183
184
185 public void setType(String type) {
186 this.type = filterEmptyString(type);
187 }
188
189
190
191
192 public String getVersion() {
193 return version;
194 }
195
196
197
198
199 public void setVersion(String version) {
200 this.version = filterEmptyString(version);
201 }
202
203
204
205
206 public String getBaseVersion() {
207 return ArtifactUtils.toSnapshotVersion(version);
208 }
209
210
211
212
213 public String getClassifier() {
214 return classifier;
215 }
216
217
218
219
220 public void setClassifier(String classifier) {
221 this.classifier = filterEmptyString(classifier);
222 }
223
224 @Override
225 public String toString() {
226 if (this.classifier == null) {
227 return groupId + ":" + artifactId + ":" + Objects.toString(version, "?") + ":" + type;
228 } else {
229 return groupId + ":" + artifactId + ":" + classifier + ":" + Objects.toString(version, "?") + ":" + type;
230 }
231 }
232
233
234
235
236 public File getOutputDirectory() {
237 return outputDirectory;
238 }
239
240
241
242
243 public void setOutputDirectory(File outputDirectory) {
244 this.outputDirectory = outputDirectory;
245 }
246
247
248
249
250 public String getDestFileName() {
251 return destFileName;
252 }
253
254
255
256
257 public void setDestFileName(String destFileName) {
258 this.destFileName = filterEmptyString(destFileName);
259 }
260
261
262
263
264 public boolean isNeedsProcessing() {
265 return this.needsProcessing;
266 }
267
268
269
270
271 public void setNeedsProcessing(boolean needsProcessing) {
272 this.needsProcessing = needsProcessing;
273 }
274
275
276
277
278 public String getOverWrite() {
279 return this.overWrite;
280 }
281
282
283
284
285 public void setOverWrite(String overWrite) {
286 this.overWrite = overWrite;
287 }
288
289
290
291
292
293 public String getEncoding() {
294 return this.encoding;
295 }
296
297
298
299
300
301 public void setEncoding(String encoding) {
302 this.encoding = encoding;
303 }
304
305
306
307
308 public Artifact getArtifact() {
309 return this.artifact;
310 }
311
312
313
314
315 public void setArtifact(Artifact artifact) {
316 this.artifact = artifact;
317 }
318
319
320
321
322 public String getExcludes() {
323 return DependencyUtil.cleanToBeTokenizedString(this.excludes);
324 }
325
326
327
328
329 public void setExcludes(String excludes) {
330 this.excludes = excludes;
331 }
332
333
334
335
336 public String getIncludes() {
337 return DependencyUtil.cleanToBeTokenizedString(this.includes);
338 }
339
340
341
342
343 public void setIncludes(String includes) {
344 this.includes = includes;
345 }
346
347
348
349
350
351
352
353 public FileMapper[] getFileMappers() {
354 return this.fileMappers;
355 }
356
357
358
359
360
361
362
363 public void setFileMappers(FileMapper[] fileMappers) {
364 this.fileMappers = fileMappers;
365 }
366 }