View Javadoc

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