1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugin.testing.stubs;
20
21 import java.io.File;
22 import java.util.Collection;
23 import java.util.List;
24
25 import org.apache.maven.artifact.Artifact;
26 import org.apache.maven.artifact.handler.ArtifactHandler;
27 import org.apache.maven.artifact.metadata.ArtifactMetadata;
28 import org.apache.maven.artifact.repository.ArtifactRepository;
29 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
30 import org.apache.maven.artifact.versioning.ArtifactVersion;
31 import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
32 import org.apache.maven.artifact.versioning.VersionRange;
33
34
35
36
37
38
39 public class ArtifactStub implements Artifact {
40 private String groupId;
41
42 private String artifactId;
43
44 private String version;
45
46 private String scope;
47
48 private String type;
49
50 private String classifier;
51
52 private File file;
53
54 private ArtifactRepository artifactRepository;
55
56
57
58
59
60
61 @Override
62 public int compareTo(Artifact artifact) {
63 return 0;
64 }
65
66
67 @Override
68 public String getGroupId() {
69 return groupId;
70 }
71
72
73 @Override
74 public String getArtifactId() {
75 return artifactId;
76 }
77
78
79 @Override
80 public String getVersion() {
81 return version;
82 }
83
84
85 @Override
86 public void setVersion(String version) {
87 this.version = version;
88 }
89
90
91 @Override
92 public String getScope() {
93 return scope;
94 }
95
96
97 @Override
98 public String getType() {
99 return type;
100 }
101
102
103
104
105
106
107 public void setType(String type) {
108 this.type = type;
109 }
110
111
112 @Override
113 public String getClassifier() {
114 return classifier;
115 }
116
117
118 @Override
119 public boolean hasClassifier() {
120 return classifier != null;
121 }
122
123
124 @Override
125 public File getFile() {
126 return file;
127 }
128
129
130 @Override
131 public void setFile(File file) {
132 this.file = file;
133 }
134
135
136
137
138
139 @Override
140 public String getBaseVersion() {
141 return null;
142 }
143
144
145
146
147
148
149 @Override
150 public void setBaseVersion(String string) {
151
152 }
153
154
155
156
157
158 @Override
159 public String getId() {
160 return null;
161 }
162
163
164
165
166
167 @Override
168 public String getDependencyConflictId() {
169 StringBuffer buffer = new StringBuffer();
170
171 buffer.append(getGroupId());
172 buffer.append(":").append(getArtifactId());
173 buffer.append(":").append(getType());
174 buffer.append(":").append(getClassifier());
175
176 return buffer.toString();
177 }
178
179
180
181
182
183
184 @Override
185 public void addMetadata(ArtifactMetadata artifactMetadata) {
186
187 }
188
189
190
191
192
193 @Override
194 public Collection<ArtifactMetadata> getMetadataList() {
195 return null;
196 }
197
198
199 @Override
200 public void setRepository(ArtifactRepository artifactRepository) {
201 this.artifactRepository = artifactRepository;
202 }
203
204
205 @Override
206 public ArtifactRepository getRepository() {
207 return artifactRepository;
208 }
209
210
211
212
213
214
215 @Override
216 public void updateVersion(String string, ArtifactRepository artifactRepository) {
217
218 }
219
220
221
222
223
224 @Override
225 public String getDownloadUrl() {
226 return null;
227 }
228
229
230
231
232
233
234 @Override
235 public void setDownloadUrl(String string) {
236
237 }
238
239
240
241
242
243 @Override
244 public ArtifactFilter getDependencyFilter() {
245 return null;
246 }
247
248
249
250
251
252
253 @Override
254 public void setDependencyFilter(ArtifactFilter artifactFilter) {
255
256 }
257
258
259
260
261
262 @Override
263 public ArtifactHandler getArtifactHandler() {
264 return null;
265 }
266
267
268
269
270
271 @Override
272 public List<String> getDependencyTrail() {
273 return null;
274 }
275
276
277
278
279
280
281 @Override
282 public void setDependencyTrail(List<String> list) {
283
284 }
285
286
287 @Override
288 public void setScope(String scope) {
289 this.scope = scope;
290 }
291
292
293
294
295
296 @Override
297 public VersionRange getVersionRange() {
298 return null;
299 }
300
301
302
303
304
305
306 @Override
307 public void setVersionRange(VersionRange versionRange) {
308
309 }
310
311
312
313
314
315
316 @Override
317 public void selectVersion(String string) {
318
319 }
320
321
322 @Override
323 public void setGroupId(String groupId) {
324 this.groupId = groupId;
325 }
326
327
328 @Override
329 public void setArtifactId(String artifactId) {
330 this.artifactId = artifactId;
331 }
332
333
334
335
336
337 @Override
338 public boolean isSnapshot() {
339 return Artifact.VERSION_FILE_PATTERN.matcher(getVersion()).matches()
340 || getVersion().endsWith(Artifact.SNAPSHOT_VERSION);
341 }
342
343
344
345
346
347
348 @Override
349 public void setResolved(boolean b) {
350
351 }
352
353
354
355
356
357 @Override
358 public boolean isResolved() {
359 return false;
360 }
361
362
363
364
365
366
367 @Override
368 public void setResolvedVersion(String string) {
369
370 }
371
372
373
374
375
376
377 @Override
378 public void setArtifactHandler(ArtifactHandler artifactHandler) {
379
380 }
381
382
383
384
385
386 @Override
387 public boolean isRelease() {
388 return !isSnapshot();
389 }
390
391
392
393
394
395
396 @Override
397 public void setRelease(boolean b) {
398
399 }
400
401
402
403
404
405 @Override
406 public List<ArtifactVersion> getAvailableVersions() {
407 return null;
408 }
409
410
411
412
413
414
415 @Override
416 public void setAvailableVersions(List<ArtifactVersion> list) {
417
418 }
419
420
421
422
423
424 @Override
425 public boolean isOptional() {
426 return false;
427 }
428
429
430
431
432
433
434 @Override
435 public void setOptional(boolean b) {
436
437 }
438
439
440
441
442
443 @Override
444 public ArtifactVersion getSelectedVersion() throws OverConstrainedVersionException {
445 return null;
446 }
447
448
449
450
451
452 @Override
453 public boolean isSelectedVersionKnown() throws OverConstrainedVersionException {
454 return false;
455 }
456
457
458
459
460 @Override
461 public String toString() {
462 StringBuffer sb = new StringBuffer();
463 if (getGroupId() != null) {
464 sb.append(getGroupId());
465 sb.append(":");
466 }
467 appendArtifactTypeClassifierString(sb);
468 if (version != null) {
469 sb.append(":");
470 sb.append(getVersion());
471 }
472 if (scope != null) {
473 sb.append(":");
474 sb.append(scope);
475 }
476 return sb.toString();
477 }
478
479 private void appendArtifactTypeClassifierString(StringBuffer sb) {
480 sb.append(getArtifactId());
481 sb.append(":");
482 sb.append(getType());
483 if (hasClassifier()) {
484 sb.append(":");
485 sb.append(getClassifier());
486 }
487 }
488
489 public boolean isFromAuthoritativeRepository() {
490 return true;
491 }
492
493 public void setFromAuthoritativeRepository(boolean fromAuthoritativeRepository) {
494
495 }
496 }