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.testUtils.stubs;
20
21 import java.io.File;
22 import java.io.IOException;
23 import java.io.Writer;
24 import java.util.Collections;
25 import java.util.List;
26 import java.util.Map;
27 import java.util.Properties;
28 import java.util.Set;
29
30 import org.apache.maven.artifact.Artifact;
31 import org.apache.maven.artifact.DefaultArtifact;
32 import org.apache.maven.artifact.DependencyResolutionRequiredException;
33 import org.apache.maven.artifact.factory.ArtifactFactory;
34 import org.apache.maven.artifact.handler.ArtifactHandler;
35 import org.apache.maven.artifact.repository.ArtifactRepository;
36 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
37 import org.apache.maven.artifact.versioning.VersionRange;
38 import org.apache.maven.model.Build;
39 import org.apache.maven.model.CiManagement;
40 import org.apache.maven.model.Contributor;
41 import org.apache.maven.model.Dependency;
42 import org.apache.maven.model.DependencyManagement;
43 import org.apache.maven.model.Developer;
44 import org.apache.maven.model.DistributionManagement;
45 import org.apache.maven.model.Extension;
46 import org.apache.maven.model.IssueManagement;
47 import org.apache.maven.model.License;
48 import org.apache.maven.model.MailingList;
49 import org.apache.maven.model.Model;
50 import org.apache.maven.model.Organization;
51 import org.apache.maven.model.Plugin;
52 import org.apache.maven.model.PluginManagement;
53 import org.apache.maven.model.Prerequisites;
54 import org.apache.maven.model.Profile;
55 import org.apache.maven.model.ReportPlugin;
56 import org.apache.maven.model.Reporting;
57 import org.apache.maven.model.Repository;
58 import org.apache.maven.model.Resource;
59 import org.apache.maven.model.Scm;
60 import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub;
61 import org.apache.maven.project.MavenProject;
62 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
63 import org.codehaus.plexus.PlexusTestCase;
64 import org.codehaus.plexus.util.xml.Xpp3Dom;
65
66
67
68
69 public class DependencyProjectStub extends MavenProject {
70 private String groupId;
71
72 private String artifactId;
73
74 private String name;
75
76 private Model model;
77
78 private MavenProject parent;
79
80 private List<Dependency> dependencies;
81
82 private File file;
83
84 private List<MavenProject> collectedProjects;
85
86 private List<Artifact> attachedArtifacts;
87
88 private List<String> compileSourceRoots;
89
90 private List<String> testCompileSourceRoots;
91
92 private List<String> scriptSourceRoots;
93
94 private List<ArtifactRepository> pluginArtifactRepositories;
95
96 private List<Profile> activeProfiles;
97
98 private Set<Artifact> dependencyArtifacts;
99
100 private DependencyManagement dependencyManagement;
101
102 private Artifact artifact;
103
104 private Model originalModel;
105
106 private boolean executionRoot;
107
108 private List<Artifact> compileArtifacts;
109
110 private List<Dependency> compileDependencies;
111
112 private List<Dependency> systemDependencies;
113
114 private List<String> testClasspathElements;
115
116 private List<Dependency> testDependencies;
117
118 private List<String> systemClasspathElements;
119
120 private List<Artifact> systemArtifacts;
121
122 private List<Artifact> testArtifacts;
123
124 private List<Artifact> runtimeArtifacts;
125
126 private List<Dependency> runtimeDependencies;
127
128 private List<String> runtimeClasspathElements;
129
130 private String modelVersion;
131
132 private String packaging;
133
134 private String inceptionYear;
135
136 private String url;
137
138 private String description;
139
140 private String version;
141
142 private String defaultGoal;
143
144 private Set<Artifact> artifacts;
145
146 private Properties properties;
147
148 public DependencyProjectStub() {
149 super((Model) null);
150 }
151
152
153 public DependencyProjectStub(Model model) {
154
155 super((Model) null);
156 }
157
158
159 public DependencyProjectStub(MavenProject project) {
160
161 super((Model) null);
162 }
163
164 public String getModulePathAdjustment(MavenProject mavenProject) throws IOException {
165 return "";
166 }
167
168 public Artifact getArtifact() {
169 if (artifact == null) {
170 ArtifactHandler ah = new DefaultArtifactHandlerStub("jar", null);
171
172 VersionRange vr = VersionRange.createFromVersion("1.0");
173 Artifact art = new DefaultArtifact("group", "artifact", vr, Artifact.SCOPE_COMPILE, "jar", null, ah, false);
174 setArtifact(art);
175 }
176 return artifact;
177 }
178
179 public void setArtifact(Artifact artifact) {
180 this.artifact = artifact;
181 }
182
183 public Model getModel() {
184 return model;
185 }
186
187 public MavenProject getParent() {
188 return parent;
189 }
190
191 public void setParent(MavenProject mavenProject) {
192 this.parent = mavenProject;
193 }
194
195 public void setRemoteArtifactRepositories(List<ArtifactRepository> list) {}
196
197 public List<ArtifactRepository> getRemoteArtifactRepositories() {
198 return Collections.emptyList();
199 }
200
201 public boolean hasParent() {
202 return (parent != null);
203 }
204
205 public File getFile() {
206 return file;
207 }
208
209 public void setFile(File file) {
210 this.file = file;
211 }
212
213 public File getBasedir() {
214 return new File(PlexusTestCase.getBasedir());
215 }
216
217 public void setDependencies(List<Dependency> list) {
218 dependencies = list;
219 }
220
221 public List<Dependency> getDependencies() {
222 if (dependencies == null) {
223 dependencies = Collections.emptyList();
224 }
225 return dependencies;
226 }
227
228 public void setDependencyManagement(DependencyManagement depMgt) {
229 this.dependencyManagement = depMgt;
230 }
231
232 public DependencyManagement getDependencyManagement() {
233 if (dependencyManagement == null) {
234 dependencyManagement = new DependencyManagement();
235 }
236
237 return dependencyManagement;
238 }
239
240 public void addCompileSourceRoot(String string) {
241 if (compileSourceRoots == null) {
242 compileSourceRoots = Collections.singletonList(string);
243 } else {
244 compileSourceRoots.add(string);
245 }
246 }
247
248 public void addScriptSourceRoot(String string) {
249 if (scriptSourceRoots == null) {
250 scriptSourceRoots = Collections.singletonList(string);
251 } else {
252 scriptSourceRoots.add(string);
253 }
254 }
255
256 public void addTestCompileSourceRoot(String string) {
257 if (testCompileSourceRoots == null) {
258 testCompileSourceRoots = Collections.singletonList(string);
259 } else {
260 testCompileSourceRoots.add(string);
261 }
262 }
263
264 public List<String> getCompileSourceRoots() {
265 return compileSourceRoots;
266 }
267
268 public List<String> getScriptSourceRoots() {
269 return scriptSourceRoots;
270 }
271
272 public List<String> getTestCompileSourceRoots() {
273 return testCompileSourceRoots;
274 }
275
276 public List<String> getCompileClasspathElements() throws DependencyResolutionRequiredException {
277 return compileSourceRoots;
278 }
279
280 public void setCompileArtifacts(List<Artifact> compileArtifacts) {
281 this.compileArtifacts = compileArtifacts;
282 }
283
284 public List<Artifact> getCompileArtifacts() {
285 return compileArtifacts;
286 }
287
288 public List<Dependency> getCompileDependencies() {
289 return compileDependencies;
290 }
291
292 public List<String> getTestClasspathElements() throws DependencyResolutionRequiredException {
293 return testClasspathElements;
294 }
295
296 public List<Artifact> getTestArtifacts() {
297 return testArtifacts;
298 }
299
300 public List<Dependency> getTestDependencies() {
301 return testDependencies;
302 }
303
304 public List<String> getRuntimeClasspathElements() throws DependencyResolutionRequiredException {
305 return runtimeClasspathElements;
306 }
307
308 public List<Artifact> getRuntimeArtifacts() {
309 return runtimeArtifacts;
310 }
311
312 public List<Dependency> getRuntimeDependencies() {
313 return runtimeDependencies;
314 }
315
316 public List<String> getSystemClasspathElements() throws DependencyResolutionRequiredException {
317 return systemClasspathElements;
318 }
319
320 public List<Artifact> getSystemArtifacts() {
321 return systemArtifacts;
322 }
323
324 public void setRuntimeClasspathElements(List<String> runtimeClasspathElements) {
325 this.runtimeClasspathElements = runtimeClasspathElements;
326 }
327
328 public void setAttachedArtifacts(List<Artifact> attachedArtifacts) {
329 this.attachedArtifacts = attachedArtifacts;
330 }
331
332 public void setCompileSourceRoots(List<String> compileSourceRoots) {
333 this.compileSourceRoots = compileSourceRoots;
334 }
335
336 public void setTestCompileSourceRoots(List<String> testCompileSourceRoots) {
337 this.testCompileSourceRoots = testCompileSourceRoots;
338 }
339
340 public void setScriptSourceRoots(List<String> scriptSourceRoots) {
341 this.scriptSourceRoots = scriptSourceRoots;
342 }
343
344 public void setCompileDependencies(List<Dependency> compileDependencies) {
345 this.compileDependencies = compileDependencies;
346 }
347
348 public void setSystemDependencies(List<Dependency> systemDependencies) {
349 this.systemDependencies = systemDependencies;
350 }
351
352 public void setTestClasspathElements(List<String> testClasspathElements) {
353 this.testClasspathElements = testClasspathElements;
354 }
355
356 public void setTestDependencies(List<Dependency> testDependencies) {
357 this.testDependencies = testDependencies;
358 }
359
360 public void setSystemClasspathElements(List<String> systemClasspathElements) {
361 this.systemClasspathElements = systemClasspathElements;
362 }
363
364 public void setSystemArtifacts(List<Artifact> systemArtifacts) {
365 this.systemArtifacts = systemArtifacts;
366 }
367
368 public void setTestArtifacts(List<Artifact> testArtifacts) {
369 this.testArtifacts = testArtifacts;
370 }
371
372 public void setRuntimeArtifacts(List<Artifact> runtimeArtifacts) {
373 this.runtimeArtifacts = runtimeArtifacts;
374 }
375
376 public void setRuntimeDependencies(List<Dependency> runtimeDependencies) {
377 this.runtimeDependencies = runtimeDependencies;
378 }
379
380 public void setModel(Model model) {
381 this.model = model;
382 }
383
384 public List<Dependency> getSystemDependencies() {
385 return systemDependencies;
386 }
387
388 public void setModelVersion(String string) {
389 this.modelVersion = string;
390 }
391
392 public String getModelVersion() {
393 return modelVersion;
394 }
395
396 public String getId() {
397 return "";
398 }
399
400 public void setGroupId(String string) {
401 this.groupId = string;
402 }
403
404 public String getGroupId() {
405 return groupId;
406 }
407
408 public void setArtifactId(String string) {
409 this.artifactId = string;
410 }
411
412 public String getArtifactId() {
413 return artifactId;
414 }
415
416 public void setName(String string) {
417 this.name = string;
418 }
419
420 public String getName() {
421 return name;
422 }
423
424 public void setVersion(String string) {
425 this.version = string;
426 }
427
428 public String getVersion() {
429 return version;
430 }
431
432 public String getPackaging() {
433 return packaging;
434 }
435
436 public void setPackaging(String string) {
437 this.packaging = string;
438 }
439
440 public void setInceptionYear(String string) {
441 this.inceptionYear = string;
442 }
443
444 public String getInceptionYear() {
445 return inceptionYear;
446 }
447
448 public void setUrl(String string) {
449 this.url = string;
450 }
451
452 public String getUrl() {
453 return url;
454 }
455
456 public Prerequisites getPrerequisites() {
457 return null;
458 }
459
460 public void setIssueManagement(IssueManagement issueManagement) {}
461
462 public CiManagement getCiManagement() {
463 return null;
464 }
465
466 public void setCiManagement(CiManagement ciManagement) {}
467
468 public IssueManagement getIssueManagement() {
469 return null;
470 }
471
472 public void setDistributionManagement(DistributionManagement distributionManagement) {}
473
474 public DistributionManagement getDistributionManagement() {
475 return null;
476 }
477
478 public void setDescription(String string) {
479 this.description = string;
480 }
481
482 public String getDescription() {
483 return description;
484 }
485
486 public void setOrganization(Organization organization) {}
487
488 public Organization getOrganization() {
489 return null;
490 }
491
492 public void setScm(Scm scm) {}
493
494 public Scm getScm() {
495 return null;
496 }
497
498 @Override
499 public void setMailingLists(List<MailingList> list) {}
500
501 public List<MailingList> getMailingLists() {
502 return Collections.emptyList();
503 }
504
505 public void addMailingList(MailingList mailingList) {}
506
507 @Override
508 public void setDevelopers(List<Developer> list) {}
509
510 public List<Developer> getDevelopers() {
511 return Collections.emptyList();
512 }
513
514 public void addDeveloper(Developer developer) {}
515
516 public void setContributors(List<Contributor> list) {}
517
518 public List<Contributor> getContributors() {
519 return Collections.emptyList();
520 }
521
522 public void addContributor(Contributor contributor) {}
523
524 public void setBuild(Build build) {}
525
526 public Build getBuild() {
527 return null;
528 }
529
530 public List<Resource> getResources() {
531 return Collections.emptyList();
532 }
533
534 public List<Resource> getTestResources() {
535 return Collections.emptyList();
536 }
537
538 public void addResource(Resource resource) {}
539
540 public void addTestResource(Resource resource) {}
541
542 public void setReporting(Reporting reporting) {}
543
544 public Reporting getReporting() {
545 return null;
546 }
547
548 public void setLicenses(List<License> list) {}
549
550 public List<License> getLicenses() {
551 return Collections.emptyList();
552 }
553
554 public void addLicense(License license) {}
555
556 public void setArtifacts(Set<Artifact> set) {
557 this.artifacts = set;
558 }
559
560 public Set<Artifact> getArtifacts() {
561 if (artifacts == null) {
562 return Collections.emptySet();
563 } else {
564 return artifacts;
565 }
566 }
567
568 public Map<String, Artifact> getArtifactMap() {
569 return Collections.emptyMap();
570 }
571
572 public void setPluginArtifacts(Set<Artifact> set) {}
573
574 public Set<Artifact> getPluginArtifacts() {
575 return Collections.emptySet();
576 }
577
578 public Map<String, Artifact> getPluginArtifactMap() {
579 return Collections.emptyMap();
580 }
581
582 public void setReportArtifacts(Set<Artifact> set) {}
583
584 public Set<Artifact> getReportArtifacts() {
585 return Collections.emptySet();
586 }
587
588 public Map<String, Artifact> getReportArtifactMap() {
589 return Collections.emptyMap();
590 }
591
592 public void setExtensionArtifacts(Set<Artifact> set) {}
593
594 public Set<Artifact> getExtensionArtifacts() {
595 return Collections.emptySet();
596 }
597
598 public Map<String, Artifact> getExtensionArtifactMap() {
599 return Collections.emptyMap();
600 }
601
602 public void setParentArtifact(Artifact artifact) {}
603
604 public Artifact getParentArtifact() {
605 return null;
606 }
607
608 public List<Repository> getRepositories() {
609 return Collections.emptyList();
610 }
611
612 public List<ReportPlugin> getReportPlugins() {
613 return Collections.emptyList();
614 }
615
616 public List<Plugin> getBuildPlugins() {
617 return Collections.emptyList();
618 }
619
620 public List<String> getModules() {
621 return Collections.singletonList("");
622 }
623
624 public PluginManagement getPluginManagement() {
625 return null;
626 }
627
628 public void addPlugin(Plugin plugin) {}
629
630 public void injectPluginManagementInfo(Plugin plugin) {}
631
632 public List<MavenProject> getCollectedProjects() {
633 return collectedProjects;
634 }
635
636 public void setCollectedProjects(List<MavenProject> list) {
637 this.collectedProjects = list;
638 }
639
640 public void setPluginArtifactRepositories(List<ArtifactRepository> list) {
641 this.pluginArtifactRepositories = list;
642 }
643
644 public List<ArtifactRepository> getPluginArtifactRepositories() {
645 return pluginArtifactRepositories;
646 }
647
648 public ArtifactRepository getDistributionManagementArtifactRepository() {
649 return null;
650 }
651
652 public List<Repository> getPluginRepositories() {
653 return Collections.emptyList();
654 }
655
656 public void setActiveProfiles(List<Profile> list) {
657 activeProfiles = list;
658 }
659
660 public List<Profile> getActiveProfiles() {
661 return activeProfiles;
662 }
663
664 public void addAttachedArtifact(Artifact theArtifact) {
665 if (attachedArtifacts == null) {
666 this.attachedArtifacts = Collections.singletonList(theArtifact);
667 } else {
668 attachedArtifacts.add(theArtifact);
669 }
670 }
671
672 public List<Artifact> getAttachedArtifacts() {
673 return attachedArtifacts;
674 }
675
676 public Xpp3Dom getGoalConfiguration(String string, String string1, String string2, String string3) {
677 return null;
678 }
679
680 public Xpp3Dom getReportConfiguration(String string, String string1, String string2) {
681 return null;
682 }
683
684 public MavenProject getExecutionProject() {
685 return null;
686 }
687
688 public void setExecutionProject(MavenProject mavenProject) {}
689
690 public void writeModel(Writer writer) throws IOException {}
691
692 public void writeOriginalModel(Writer writer) throws IOException {}
693
694 public Set<Artifact> getDependencyArtifacts() {
695 return dependencyArtifacts;
696 }
697
698 public void setDependencyArtifacts(Set<Artifact> set) {
699 this.dependencyArtifacts = set;
700 }
701
702 public void setReleaseArtifactRepository(ArtifactRepository artifactRepository) {
703
704 }
705
706 public void setSnapshotArtifactRepository(ArtifactRepository artifactRepository) {
707
708 }
709
710 public void setOriginalModel(Model model) {
711 this.originalModel = model;
712 }
713
714 public Model getOriginalModel() {
715 return originalModel;
716 }
717
718 public List<Extension> getBuildExtensions() {
719 return Collections.emptyList();
720 }
721
722 @Override
723 public Set<Artifact> createArtifacts(ArtifactFactory artifactFactory, String string, ArtifactFilter artifactFilter)
724 throws InvalidDependencyVersionException {
725 return Collections.emptySet();
726 }
727
728 public void addProjectReference(MavenProject mavenProject) {}
729
730 public void attachArtifact(String string, String string1, File theFile) {}
731
732 public Properties getProperties() {
733 if (properties == null) {
734 properties = new Properties();
735 }
736 return properties;
737 }
738
739 public List<String> getFilters() {
740 return Collections.singletonList("");
741 }
742
743 public Map<String, MavenProject> getProjectReferences() {
744 return Collections.emptyMap();
745 }
746
747 public boolean isExecutionRoot() {
748 return executionRoot;
749 }
750
751 public void setExecutionRoot(boolean b) {
752 this.executionRoot = b;
753 }
754
755 public String getDefaultGoal() {
756 return defaultGoal;
757 }
758
759 public Artifact replaceWithActiveArtifact(Artifact theArtifact) {
760 return null;
761 }
762 }