1 package org.apache.maven.plugin.dependency.testUtils.stubs;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.io.IOException;
24 import java.io.Writer;
25 import java.util.Collections;
26 import java.util.List;
27 import java.util.Map;
28 import java.util.Properties;
29 import java.util.Set;
30
31 import org.apache.maven.artifact.Artifact;
32 import org.apache.maven.artifact.DefaultArtifact;
33 import org.apache.maven.artifact.DependencyResolutionRequiredException;
34 import org.apache.maven.artifact.factory.ArtifactFactory;
35 import org.apache.maven.artifact.handler.ArtifactHandler;
36 import org.apache.maven.artifact.repository.ArtifactRepository;
37 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
38 import org.apache.maven.artifact.versioning.VersionRange;
39 import org.apache.maven.model.Build;
40 import org.apache.maven.model.CiManagement;
41 import org.apache.maven.model.Contributor;
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.IssueManagement;
46 import org.apache.maven.model.License;
47 import org.apache.maven.model.MailingList;
48 import org.apache.maven.model.Model;
49 import org.apache.maven.model.Organization;
50 import org.apache.maven.model.Plugin;
51 import org.apache.maven.model.PluginManagement;
52 import org.apache.maven.model.Prerequisites;
53 import org.apache.maven.model.Reporting;
54 import org.apache.maven.model.Resource;
55 import org.apache.maven.model.Scm;
56 import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub;
57 import org.apache.maven.project.MavenProject;
58 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
59 import org.codehaus.plexus.PlexusTestCase;
60 import org.codehaus.plexus.util.xml.Xpp3Dom;
61
62
63
64
65
66 public class DependencyProjectStub
67 extends MavenProject
68 {
69 private String groupId;
70
71 private String artifactId;
72
73 private String name;
74
75 private Model model;
76
77 private MavenProject parent;
78
79 private List dependencies;
80
81 private File file;
82
83 private List collectedProjects;
84
85 private List attachedArtifacts;
86
87 private List compileSourceRoots;
88
89 private List testCompileSourceRoots;
90
91 private List scriptSourceRoots;
92
93 private List pluginArtifactRepositories;
94
95
96
97
98
99 private List activeProfiles;
100
101 private Set dependencyArtifacts;
102
103 private DependencyManagement dependencyManagement;
104
105 private Artifact artifact;
106
107
108
109 private Model originalModel;
110
111
112
113
114
115
116
117
118
119
120
121 private boolean executionRoot;
122
123 private List compileArtifacts;
124
125 private List compileDependencies;
126
127 private List systemDependencies;
128
129 private List testClasspathElements;
130
131 private List testDependencies;
132
133 private List systemClasspathElements;
134
135 private List systemArtifacts;
136
137 private List testArtifacts;
138
139 private List runtimeArtifacts;
140
141 private List runtimeDependencies;
142
143 private List runtimeClasspathElements;
144
145 private String modelVersion;
146
147 private String packaging;
148
149 private String inceptionYear;
150
151 private String url;
152
153 private String description;
154
155 private String version;
156
157 private String defaultGoal;
158
159 private Set artifacts;
160
161 private Properties properties;
162
163 public DependencyProjectStub()
164 {
165 super( (Model) null );
166 }
167
168
169 public DependencyProjectStub( Model model )
170 {
171
172 super( (Model) null );
173 }
174
175
176 public DependencyProjectStub( MavenProject project )
177 {
178
179 super( (Model) null );
180 }
181
182 public String getModulePathAdjustment( MavenProject mavenProject )
183 throws IOException
184 {
185 return "";
186 }
187
188 public Artifact getArtifact()
189 {
190 if ( artifact == null )
191 {
192 ArtifactHandler ah = new DefaultArtifactHandlerStub( "jar", null );
193
194 VersionRange vr = VersionRange.createFromVersion( "1.0" );
195 Artifact art = new DefaultArtifact( "group", "artifact", vr, Artifact.SCOPE_COMPILE, "jar", null, ah, false );
196 setArtifact( art );
197 }
198 return artifact;
199 }
200
201 public void setArtifact( Artifact artifact )
202 {
203 this.artifact = artifact;
204 }
205
206 public Model getModel()
207 {
208 return model;
209 }
210
211 public MavenProject getParent()
212 {
213 return parent;
214 }
215
216 public void setParent( MavenProject mavenProject )
217 {
218 this.parent = mavenProject;
219 }
220
221 public void setRemoteArtifactRepositories( List list )
222 {
223
224 }
225
226 public List getRemoteArtifactRepositories()
227 {
228 return Collections.singletonList( "" );
229 }
230
231 public boolean hasParent()
232 {
233 return ( parent != null );
234 }
235
236 public File getFile()
237 {
238 return file;
239 }
240
241 public void setFile( File file )
242 {
243 this.file = file;
244 }
245
246 public File getBasedir()
247 {
248 return new File( PlexusTestCase.getBasedir() );
249 }
250
251 public void setDependencies( List list )
252 {
253 dependencies = list;
254 }
255
256 public List getDependencies()
257 {
258 if ( dependencies == null )
259 {
260 dependencies = Collections.EMPTY_LIST;
261 }
262 return dependencies;
263 }
264
265 public void setDependencyManagement(DependencyManagement depMgt)
266 {
267 this.dependencyManagement = depMgt;
268 }
269 public DependencyManagement getDependencyManagement()
270 {
271 if ( dependencyManagement == null )
272 {
273 dependencyManagement = new DependencyManagement();
274 }
275
276 return dependencyManagement;
277 }
278
279 public void addCompileSourceRoot( String string )
280 {
281 if ( compileSourceRoots == null )
282 {
283 compileSourceRoots = Collections.singletonList( string );
284 }
285 else
286 {
287 compileSourceRoots.add( string );
288 }
289 }
290
291 public void addScriptSourceRoot( String string )
292 {
293 if ( scriptSourceRoots == null )
294 {
295 scriptSourceRoots = Collections.singletonList( string );
296 }
297 else
298 {
299 scriptSourceRoots.add( string );
300 }
301 }
302
303 public void addTestCompileSourceRoot( String string )
304 {
305 if ( testCompileSourceRoots == null )
306 {
307 testCompileSourceRoots = Collections.singletonList( string );
308 }
309 else
310 {
311 testCompileSourceRoots.add( string );
312 }
313 }
314
315 public List getCompileSourceRoots()
316 {
317 return compileSourceRoots;
318 }
319
320 public List getScriptSourceRoots()
321 {
322 return scriptSourceRoots;
323 }
324
325 public List getTestCompileSourceRoots()
326 {
327 return testCompileSourceRoots;
328 }
329
330 public List getCompileClasspathElements()
331 throws DependencyResolutionRequiredException
332 {
333 return compileSourceRoots;
334 }
335
336 public void setCompileArtifacts( List compileArtifacts )
337 {
338 this.compileArtifacts = compileArtifacts;
339 }
340
341 public List getCompileArtifacts()
342 {
343 return compileArtifacts;
344 }
345
346 public List getCompileDependencies()
347 {
348 return compileDependencies;
349 }
350
351 public List getTestClasspathElements()
352 throws DependencyResolutionRequiredException
353 {
354 return testClasspathElements;
355 }
356
357 public List getTestArtifacts()
358 {
359 return testArtifacts;
360 }
361
362 public List getTestDependencies()
363 {
364 return testDependencies;
365 }
366
367 public List getRuntimeClasspathElements()
368 throws DependencyResolutionRequiredException
369 {
370 return runtimeClasspathElements;
371 }
372
373 public List getRuntimeArtifacts()
374 {
375 return runtimeArtifacts;
376 }
377
378 public List getRuntimeDependencies()
379 {
380 return runtimeDependencies;
381 }
382
383 public List getSystemClasspathElements()
384 throws DependencyResolutionRequiredException
385 {
386 return systemClasspathElements;
387 }
388
389 public List getSystemArtifacts()
390 {
391 return systemArtifacts;
392 }
393
394 public void setRuntimeClasspathElements( List runtimeClasspathElements )
395 {
396 this.runtimeClasspathElements = runtimeClasspathElements;
397 }
398
399 public void setAttachedArtifacts( List attachedArtifacts )
400 {
401 this.attachedArtifacts = attachedArtifacts;
402 }
403
404 public void setCompileSourceRoots( List compileSourceRoots )
405 {
406 this.compileSourceRoots = compileSourceRoots;
407 }
408
409 public void setTestCompileSourceRoots( List testCompileSourceRoots )
410 {
411 this.testCompileSourceRoots = testCompileSourceRoots;
412 }
413
414 public void setScriptSourceRoots( List scriptSourceRoots )
415 {
416 this.scriptSourceRoots = scriptSourceRoots;
417 }
418
419 public void setArtifactMap( Map artifactMap )
420 {
421
422 }
423
424 public void setPluginArtifactMap( Map pluginArtifactMap )
425 {
426
427 }
428
429 public void setReportArtifactMap( Map reportArtifactMap )
430 {
431
432 }
433
434 public void setExtensionArtifactMap( Map extensionArtifactMap )
435 {
436
437 }
438
439 public void setProjectReferences( Map projectReferences )
440 {
441
442 }
443
444 public void setBuildOverlay( Build buildOverlay )
445 {
446
447 }
448
449 public void setCompileDependencies( List compileDependencies )
450 {
451 this.compileDependencies = compileDependencies;
452 }
453
454 public void setSystemDependencies( List systemDependencies )
455 {
456 this.systemDependencies = systemDependencies;
457 }
458
459 public void setTestClasspathElements( List testClasspathElements )
460 {
461 this.testClasspathElements = testClasspathElements;
462 }
463
464 public void setTestDependencies( List testDependencies )
465 {
466 this.testDependencies = testDependencies;
467 }
468
469 public void setSystemClasspathElements( List systemClasspathElements )
470 {
471 this.systemClasspathElements = systemClasspathElements;
472 }
473
474 public void setSystemArtifacts( List systemArtifacts )
475 {
476 this.systemArtifacts = systemArtifacts;
477 }
478
479 public void setTestArtifacts( List testArtifacts )
480 {
481 this.testArtifacts = testArtifacts;
482 }
483
484 public void setRuntimeArtifacts( List runtimeArtifacts )
485 {
486 this.runtimeArtifacts = runtimeArtifacts;
487 }
488
489 public void setRuntimeDependencies( List runtimeDependencies )
490 {
491 this.runtimeDependencies = runtimeDependencies;
492 }
493
494 public void setModel( Model model )
495 {
496 this.model = model;
497 }
498
499 public List getSystemDependencies()
500 {
501 return systemDependencies;
502 }
503
504 public void setModelVersion( String string )
505 {
506 this.modelVersion = string;
507 }
508
509 public String getModelVersion()
510 {
511 return modelVersion;
512 }
513
514 public String getId()
515 {
516 return "";
517 }
518
519 public void setGroupId( String string )
520 {
521 this.groupId = string;
522 }
523
524 public String getGroupId()
525 {
526 return groupId;
527 }
528
529 public void setArtifactId( String string )
530 {
531 this.artifactId = string;
532 }
533
534 public String getArtifactId()
535 {
536 return artifactId;
537 }
538
539 public void setName( String string )
540 {
541 this.name = string;
542 }
543
544 public String getName()
545 {
546 return name;
547 }
548
549 public void setVersion( String string )
550 {
551 this.version = string;
552 }
553
554 public String getVersion()
555 {
556 return version;
557 }
558
559 public String getPackaging()
560 {
561 return packaging;
562 }
563
564 public void setPackaging( String string )
565 {
566 this.packaging = string;
567 }
568
569 public void setInceptionYear( String string )
570 {
571 this.inceptionYear = string;
572 }
573
574 public String getInceptionYear()
575 {
576 return inceptionYear;
577 }
578
579 public void setUrl( String string )
580 {
581 this.url = string;
582 }
583
584 public String getUrl()
585 {
586 return url;
587 }
588
589 public Prerequisites getPrerequisites()
590 {
591 return null;
592 }
593
594 public void setIssueManagement( IssueManagement issueManagement )
595 {
596
597 }
598
599 public CiManagement getCiManagement()
600 {
601 return null;
602 }
603
604 public void setCiManagement( CiManagement ciManagement )
605 {
606
607 }
608
609 public IssueManagement getIssueManagement()
610 {
611 return null;
612 }
613
614 public void setDistributionManagement( DistributionManagement distributionManagement )
615 {
616
617 }
618
619 public DistributionManagement getDistributionManagement()
620 {
621 return null;
622 }
623
624 public void setDescription( String string )
625 {
626 this.description = string;
627 }
628
629 public String getDescription()
630 {
631 return description;
632 }
633
634 public void setOrganization( Organization organization )
635 {
636
637 }
638
639 public Organization getOrganization()
640 {
641 return null;
642 }
643
644 public void setScm( Scm scm )
645 {
646
647 }
648
649 public Scm getScm()
650 {
651 return null;
652 }
653
654 public void setMailingLists( List list )
655 {
656
657 }
658
659 public List getMailingLists()
660 {
661 return Collections.singletonList( "" );
662 }
663
664 public void addMailingList( MailingList mailingList )
665 {
666
667 }
668
669 public void setDevelopers( List list )
670 {
671
672 }
673
674 public List getDevelopers()
675 {
676 return Collections.singletonList( "" );
677 }
678
679 public void addDeveloper( Developer developer )
680 {
681
682 }
683
684 public void setContributors( List list )
685 {
686
687 }
688
689 public List getContributors()
690 {
691 return Collections.singletonList( "" );
692 }
693
694 public void addContributor( Contributor contributor )
695 {
696
697 }
698
699 public void setBuild( Build build )
700 {
701
702 }
703
704 public Build getBuild()
705 {
706 return null;
707 }
708
709 public List getResources()
710 {
711 return Collections.singletonList( "" );
712 }
713
714 public List getTestResources()
715 {
716 return Collections.singletonList( "" );
717 }
718
719 public void addResource( Resource resource )
720 {
721
722 }
723
724 public void addTestResource( Resource resource )
725 {
726
727 }
728
729 public void setReporting( Reporting reporting )
730 {
731
732 }
733
734 public Reporting getReporting()
735 {
736 return null;
737 }
738
739 public void setLicenses( List list )
740 {
741
742 }
743
744 public List getLicenses()
745 {
746 return Collections.singletonList( "" );
747 }
748
749 public void addLicense( License license )
750 {
751
752 }
753
754 public void setArtifacts( Set set )
755 {
756 this.artifacts = set;
757 }
758
759 public Set getArtifacts()
760 {
761 if ( artifacts == null )
762 {
763 return Collections.EMPTY_SET;
764 }
765 else
766 {
767 return artifacts;
768 }
769 }
770
771 public Map getArtifactMap()
772 {
773 return Collections.singletonMap( "", "" );
774 }
775
776 public void setPluginArtifacts( Set set )
777 {
778
779 }
780
781 public Set getPluginArtifacts()
782 {
783 return Collections.singleton( "" );
784 }
785
786 public Map getPluginArtifactMap()
787 {
788 return Collections.singletonMap( "", "" );
789 }
790
791 public void setReportArtifacts( Set set )
792 {
793
794 }
795
796 public Set getReportArtifacts()
797 {
798 return Collections.singleton( "" );
799 }
800
801 public Map getReportArtifactMap()
802 {
803 return Collections.singletonMap( "", "" );
804 }
805
806 public void setExtensionArtifacts( Set set )
807 {
808
809 }
810
811 public Set getExtensionArtifacts()
812 {
813 return Collections.singleton( "" );
814 }
815
816 public Map getExtensionArtifactMap()
817 {
818 return Collections.singletonMap( "", "" );
819 }
820
821 public void setParentArtifact( Artifact artifact )
822 {
823
824 }
825
826 public Artifact getParentArtifact()
827 {
828 return null;
829 }
830
831 public List getRepositories()
832 {
833 return Collections.singletonList( "" );
834 }
835
836 public List getReportPlugins()
837 {
838 return Collections.singletonList( "" );
839 }
840
841 public List getBuildPlugins()
842 {
843 return Collections.singletonList( "" );
844 }
845
846 public List getModules()
847 {
848 return Collections.singletonList( "" );
849 }
850
851 public PluginManagement getPluginManagement()
852 {
853 return null;
854 }
855
856 public void addPlugin( Plugin plugin )
857 {
858
859 }
860
861 public void injectPluginManagementInfo( Plugin plugin )
862 {
863
864 }
865
866 public List getCollectedProjects()
867 {
868 return collectedProjects;
869 }
870
871 public void setCollectedProjects( List list )
872 {
873 this.collectedProjects = list;
874 }
875
876 public void setPluginArtifactRepositories( List list )
877 {
878 this.pluginArtifactRepositories = list;
879 }
880
881 public List getPluginArtifactRepositories()
882 {
883 return pluginArtifactRepositories;
884 }
885
886 public ArtifactRepository getDistributionManagementArtifactRepository()
887 {
888 return null;
889 }
890
891 public List getPluginRepositories()
892 {
893 return Collections.singletonList( "" );
894 }
895
896 public void setActiveProfiles( List list )
897 {
898 activeProfiles = list;
899 }
900
901 public List getActiveProfiles()
902 {
903 return activeProfiles;
904 }
905
906 public void addAttachedArtifact( Artifact theArtifact )
907 {
908 if ( attachedArtifacts == null )
909 {
910 this.attachedArtifacts = Collections.singletonList( theArtifact );
911 }
912 else
913 {
914 attachedArtifacts.add( theArtifact );
915 }
916 }
917
918 public List getAttachedArtifacts()
919 {
920 return attachedArtifacts;
921 }
922
923 public Xpp3Dom getGoalConfiguration( String string, String string1, String string2, String string3 )
924 {
925 return null;
926 }
927
928 public Xpp3Dom getReportConfiguration( String string, String string1, String string2 )
929 {
930 return null;
931 }
932
933 public MavenProject getExecutionProject()
934 {
935 return null;
936 }
937
938 public void setExecutionProject( MavenProject mavenProject )
939 {
940
941 }
942
943 public void writeModel( Writer writer )
944 throws IOException
945 {
946
947 }
948
949 public void writeOriginalModel( Writer writer )
950 throws IOException
951 {
952
953 }
954
955 public Set getDependencyArtifacts()
956 {
957 return dependencyArtifacts;
958 }
959
960 public void setDependencyArtifacts( Set set )
961 {
962 this.dependencyArtifacts = set;
963 }
964
965 public void setReleaseArtifactRepository( ArtifactRepository artifactRepository )
966 {
967
968 }
969
970 public void setSnapshotArtifactRepository( ArtifactRepository artifactRepository )
971 {
972
973 }
974
975 public void setOriginalModel( Model model )
976 {
977 this.originalModel = model;
978 }
979
980 public Model getOriginalModel()
981 {
982 return originalModel;
983 }
984
985 public List getBuildExtensions()
986 {
987 return Collections.singletonList( "" );
988 }
989
990 public Set createArtifacts( ArtifactFactory artifactFactory, String string, ArtifactFilter artifactFilter )
991 throws InvalidDependencyVersionException
992 {
993 return Collections.EMPTY_SET;
994 }
995
996 public void addProjectReference( MavenProject mavenProject )
997 {
998
999 }
1000
1001 public void attachArtifact( String string, String string1, File theFile )
1002 {
1003
1004 }
1005
1006 public Properties getProperties()
1007 {
1008 if ( properties == null )
1009 {
1010 properties = new Properties();
1011 }
1012 return properties;
1013 }
1014
1015 public List getFilters()
1016 {
1017 return Collections.singletonList( "" );
1018 }
1019
1020 public Map getProjectReferences()
1021 {
1022 return Collections.singletonMap( "", "" );
1023 }
1024
1025 public boolean isExecutionRoot()
1026 {
1027 return executionRoot;
1028 }
1029
1030 public void setExecutionRoot( boolean b )
1031 {
1032 this.executionRoot = b;
1033 }
1034
1035 public String getDefaultGoal()
1036 {
1037 return defaultGoal;
1038 }
1039
1040 public Artifact replaceWithActiveArtifact( Artifact theArtifact )
1041 {
1042 return null;
1043 }
1044 }