View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  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,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.plugin.testing.stubs;
20  
21  import java.io.File;
22  import java.io.IOException;
23  import java.io.Writer;
24  import java.util.ArrayList;
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.DependencyResolutionRequiredException;
33  import org.apache.maven.artifact.factory.ArtifactFactory;
34  import org.apache.maven.artifact.repository.ArtifactRepository;
35  import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
36  import org.apache.maven.model.Build;
37  import org.apache.maven.model.CiManagement;
38  import org.apache.maven.model.Contributor;
39  import org.apache.maven.model.Dependency;
40  import org.apache.maven.model.DependencyManagement;
41  import org.apache.maven.model.Developer;
42  import org.apache.maven.model.DistributionManagement;
43  import org.apache.maven.model.Extension;
44  import org.apache.maven.model.IssueManagement;
45  import org.apache.maven.model.License;
46  import org.apache.maven.model.MailingList;
47  import org.apache.maven.model.Model;
48  import org.apache.maven.model.Organization;
49  import org.apache.maven.model.Plugin;
50  import org.apache.maven.model.PluginManagement;
51  import org.apache.maven.model.Prerequisites;
52  import org.apache.maven.model.Profile;
53  import org.apache.maven.model.ReportPlugin;
54  import org.apache.maven.model.Reporting;
55  import org.apache.maven.model.Repository;
56  import org.apache.maven.model.Resource;
57  import org.apache.maven.model.Scm;
58  import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
59  import org.apache.maven.project.MavenProject;
60  import org.codehaus.plexus.PlexusTestCase;
61  import org.codehaus.plexus.util.ReaderFactory;
62  import org.codehaus.plexus.util.xml.Xpp3Dom;
63  import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
64  
65  /**
66   * Very simple stub of <code>MavenProject</code> object, going to take a lot of work to make it
67   * useful as a stub though.
68   *
69   * @author jesse
70   */
71  public class MavenProjectStub extends MavenProject {
72      private String groupId;
73  
74      private String artifactId;
75  
76      private String name;
77  
78      private Model model;
79  
80      private MavenProject parent;
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 ArtifactRepository releaseArtifactRepository;
97  
98      private ArtifactRepository snapshotArtifactRepository;
99  
100     private List<Profile> activeProfiles;
101 
102     private Set<Artifact> dependencyArtifacts;
103 
104     private Artifact artifact;
105 
106     private Map<String, Artifact> artifactMap;
107 
108     private Model originalModel;
109 
110     private Map<String, Artifact> pluginArtifactMap;
111 
112     private Map<String, Artifact> reportArtifactMap;
113 
114     private Map<String, Artifact> extensionArtifactMap;
115 
116     private Map<String, MavenProject> projectReferences;
117 
118     private Build buildOverlay;
119 
120     private boolean executionRoot;
121 
122     private List<Artifact> compileArtifacts;
123 
124     private List<Dependency> compileDependencies;
125 
126     private List<Dependency> systemDependencies;
127 
128     private List<String> testClasspathElements;
129 
130     private List<Dependency> testDependencies;
131 
132     private List<String> systemClasspathElements;
133 
134     private List<Artifact> systemArtifacts;
135 
136     private List<Artifact> testArtifacts;
137 
138     private List<Artifact> runtimeArtifacts;
139 
140     private List<Dependency> runtimeDependencies;
141 
142     private List<String> runtimeClasspathElements;
143 
144     private String modelVersion;
145 
146     private String packaging;
147 
148     private String inceptionYear;
149 
150     private String url;
151 
152     private String description;
153 
154     private String version;
155 
156     private String defaultGoal;
157 
158     private List<License> licenses;
159 
160     private Build build;
161 
162     /**
163      * Default constructor
164      */
165     public MavenProjectStub() {
166         this(new Model());
167     }
168 
169     /**
170      * @param model the given model
171      */
172     public MavenProjectStub(Model model) {
173         super((Model) null);
174         this.model = model;
175     }
176 
177     /**
178      * Loads the model for this stub from the specified POM. For convenience, any checked exception caused by I/O or
179      * parser errors will be wrapped into an unchecked exception.
180      *
181      * @param pomFile The path to the POM file to load, must not be <code>null</code>. If this path is relative, it
182      *            is resolved against the return value of {@link #getBasedir()}.
183      */
184     protected void readModel(File pomFile) {
185         if (!pomFile.isAbsolute()) {
186             pomFile = new File(getBasedir(), pomFile.getPath());
187         }
188         try {
189             setModel(new MavenXpp3Reader().read(ReaderFactory.newXmlReader(pomFile)));
190         } catch (IOException e) {
191             throw new RuntimeException("Failed to read POM file: " + pomFile, e);
192         } catch (XmlPullParserException e) {
193             throw new RuntimeException("Failed to parse POM file: " + pomFile, e);
194         }
195     }
196 
197     /**
198      * No project model is associated
199      *
200      * @param project the given project
201      */
202     public MavenProjectStub(MavenProject project) {
203         super((Model) null);
204     }
205 
206     /**
207      * @param mavenProject
208      * @return an empty String
209      * @throws IOException if any
210      */
211     @Override
212     public String getModulePathAdjustment(MavenProject mavenProject) throws IOException {
213         return "";
214     }
215 
216     /** {@inheritDoc} */
217     @Override
218     public Artifact getArtifact() {
219         return artifact;
220     }
221 
222     /** {@inheritDoc} */
223     @Override
224     public void setArtifact(Artifact artifact) {
225         this.artifact = artifact;
226     }
227 
228     /** {@inheritDoc} */
229     @Override
230     public Model getModel() {
231         return model;
232     }
233 
234     /** {@inheritDoc} */
235     @Override
236     public MavenProject getParent() {
237         return parent;
238     }
239 
240     /** {@inheritDoc} */
241     @Override
242     public void setParent(MavenProject mavenProject) {
243         this.parent = mavenProject;
244     }
245 
246     /**
247      * By default, do nothing.
248      *
249      * @see org.apache.maven.project.MavenProject#setRemoteArtifactRepositories(java.util.List)
250      */
251     @Override
252     public void setRemoteArtifactRepositories(List<ArtifactRepository> list) {
253         // nop
254     }
255 
256     /**
257      * By default, return <code>Collections.EMPTY_LIST</code>.
258      *
259      * @see org.apache.maven.project.MavenProject#getRemoteArtifactRepositories()
260      */
261     @Override
262     public List<ArtifactRepository> getRemoteArtifactRepositories() {
263         return Collections.<ArtifactRepository>emptyList();
264     }
265 
266     /** {@inheritDoc} */
267     @Override
268     public boolean hasParent() {
269         if (parent != null) {
270             return true;
271         }
272 
273         return false;
274     }
275 
276     /** {@inheritDoc} */
277     @Override
278     public File getFile() {
279         return file;
280     }
281 
282     /** {@inheritDoc} */
283     @Override
284     public void setFile(File file) {
285         this.file = file;
286     }
287 
288     /** {@inheritDoc} */
289     @Override
290     public File getBasedir() {
291         return new File(PlexusTestCase.getBasedir());
292     }
293 
294     /**
295      * By default, do nothing.
296      *
297      * @see org.apache.maven.project.MavenProject#setDependencies(java.util.List)
298      */
299     @Override
300     public void setDependencies(List<Dependency> list) {
301         // nop
302     }
303 
304     /**
305      * By default, return <code>Collections.EMPTY_LIST</code>.
306      *
307      * @see org.apache.maven.project.MavenProject#getDependencies()
308      */
309     @Override
310     public List<Dependency> getDependencies() {
311         return Collections.<Dependency>emptyList();
312     }
313 
314     /**
315      * By default, return <code>null</code>.
316      *
317      * @see org.apache.maven.project.MavenProject#getDependencyManagement()
318      */
319     @Override
320     public DependencyManagement getDependencyManagement() {
321         return null;
322     }
323 
324     /** {@inheritDoc} */
325     @Override
326     public void addCompileSourceRoot(String string) {
327         if (compileSourceRoots == null) {
328             compileSourceRoots = new ArrayList<>(Collections.singletonList(string));
329         } else {
330             compileSourceRoots.add(string);
331         }
332     }
333 
334     /** {@inheritDoc} */
335     @Override
336     public void addScriptSourceRoot(String string) {
337         if (scriptSourceRoots == null) {
338             scriptSourceRoots = new ArrayList<>(Collections.singletonList(string));
339         } else {
340             scriptSourceRoots.add(string);
341         }
342     }
343 
344     /** {@inheritDoc} */
345     @Override
346     public void addTestCompileSourceRoot(String string) {
347         if (testCompileSourceRoots == null) {
348             testCompileSourceRoots = new ArrayList<>(Collections.singletonList(string));
349         } else {
350             testCompileSourceRoots.add(string);
351         }
352     }
353 
354     /** {@inheritDoc} */
355     @Override
356     public List<String> getCompileSourceRoots() {
357         return compileSourceRoots;
358     }
359 
360     /** {@inheritDoc} */
361     @Override
362     public List<String> getScriptSourceRoots() {
363         return scriptSourceRoots;
364     }
365 
366     /** {@inheritDoc} */
367     @Override
368     public List<String> getTestCompileSourceRoots() {
369         return testCompileSourceRoots;
370     }
371 
372     /** {@inheritDoc} */
373     @Override
374     public List<String> getCompileClasspathElements() throws DependencyResolutionRequiredException {
375         return compileSourceRoots;
376     }
377 
378     /**
379      * @param compileArtifacts
380      */
381     public void setCompileArtifacts(List<Artifact> compileArtifacts) {
382         this.compileArtifacts = compileArtifacts;
383     }
384 
385     /** {@inheritDoc} */
386     @Override
387     public List<Artifact> getCompileArtifacts() {
388         return compileArtifacts;
389     }
390 
391     /** {@inheritDoc} */
392     @Override
393     public List<Dependency> getCompileDependencies() {
394         return compileDependencies;
395     }
396 
397     /** {@inheritDoc} */
398     @Override
399     public List<String> getTestClasspathElements() throws DependencyResolutionRequiredException {
400         return testClasspathElements;
401     }
402 
403     /** {@inheritDoc} */
404     @Override
405     public List<Artifact> getTestArtifacts() {
406         return testArtifacts;
407     }
408 
409     /** {@inheritDoc} */
410     @Override
411     public List<Dependency> getTestDependencies() {
412         return testDependencies;
413     }
414 
415     /** {@inheritDoc} */
416     @Override
417     public List<String> getRuntimeClasspathElements() throws DependencyResolutionRequiredException {
418         return runtimeClasspathElements;
419     }
420 
421     /** {@inheritDoc} */
422     @Override
423     public List<Artifact> getRuntimeArtifacts() {
424         return runtimeArtifacts;
425     }
426 
427     /** {@inheritDoc} */
428     @Override
429     public List<Dependency> getRuntimeDependencies() {
430         return runtimeDependencies;
431     }
432 
433     /** {@inheritDoc} */
434     @Override
435     public List<String> getSystemClasspathElements() throws DependencyResolutionRequiredException {
436         return systemClasspathElements;
437     }
438 
439     /** {@inheritDoc} */
440     @Override
441     public List<Artifact> getSystemArtifacts() {
442         return systemArtifacts;
443     }
444 
445     /**
446      * @param runtimeClasspathElements
447      */
448     public void setRuntimeClasspathElements(List<String> runtimeClasspathElements) {
449         this.runtimeClasspathElements = runtimeClasspathElements;
450     }
451 
452     /**
453      * @param attachedArtifacts
454      */
455     @Override
456     public void setAttachedArtifacts(List<Artifact> attachedArtifacts) {
457         this.attachedArtifacts = attachedArtifacts;
458     }
459 
460     /**
461      * @param compileSourceRoots
462      */
463     @Override
464     public void setCompileSourceRoots(List<String> compileSourceRoots) {
465         this.compileSourceRoots = compileSourceRoots;
466     }
467 
468     /**
469      * @param testCompileSourceRoots
470      */
471     @Override
472     public void setTestCompileSourceRoots(List<String> testCompileSourceRoots) {
473         this.testCompileSourceRoots = testCompileSourceRoots;
474     }
475 
476     /**
477      * @param scriptSourceRoots
478      */
479     @Override
480     public void setScriptSourceRoots(List<String> scriptSourceRoots) {
481         this.scriptSourceRoots = scriptSourceRoots;
482     }
483 
484     /**
485      * @param artifactMap
486      */
487     public void setArtifactMap(Map<String, Artifact> artifactMap) {
488         this.artifactMap = artifactMap;
489     }
490 
491     /**
492      * @param pluginArtifactMap
493      */
494     public void setPluginArtifactMap(Map<String, Artifact> pluginArtifactMap) {
495         this.pluginArtifactMap = pluginArtifactMap;
496     }
497 
498     /**
499      * @param reportArtifactMap
500      */
501     public void setReportArtifactMap(Map<String, Artifact> reportArtifactMap) {
502         this.reportArtifactMap = reportArtifactMap;
503     }
504 
505     /**
506      * @param extensionArtifactMap
507      */
508     public void setExtensionArtifactMap(Map<String, Artifact> extensionArtifactMap) {
509         this.extensionArtifactMap = extensionArtifactMap;
510     }
511 
512     /**
513      * @param projectReferences
514      */
515     public void setProjectReferences(Map<String, MavenProject> projectReferences) {
516         this.projectReferences = projectReferences;
517     }
518 
519     /**
520      * @param buildOverlay
521      */
522     public void setBuildOverlay(Build buildOverlay) {
523         this.buildOverlay = buildOverlay;
524     }
525 
526     /**
527      * @param compileDependencies
528      */
529     public void setCompileDependencies(List<Dependency> compileDependencies) {
530         this.compileDependencies = compileDependencies;
531     }
532 
533     /**
534      * @param systemDependencies
535      */
536     public void setSystemDependencies(List<Dependency> systemDependencies) {
537         this.systemDependencies = systemDependencies;
538     }
539 
540     /**
541      * @param testClasspathElements
542      */
543     public void setTestClasspathElements(List<String> testClasspathElements) {
544         this.testClasspathElements = testClasspathElements;
545     }
546 
547     /**
548      * @param testDependencies
549      */
550     public void setTestDependencies(List<Dependency> testDependencies) {
551         this.testDependencies = testDependencies;
552     }
553 
554     /**
555      * @param systemClasspathElements
556      */
557     public void setSystemClasspathElements(List<String> systemClasspathElements) {
558         this.systemClasspathElements = systemClasspathElements;
559     }
560 
561     /**
562      * @param systemArtifacts
563      */
564     public void setSystemArtifacts(List<Artifact> systemArtifacts) {
565         this.systemArtifacts = systemArtifacts;
566     }
567 
568     /**
569      * @param testArtifacts
570      */
571     public void setTestArtifacts(List<Artifact> testArtifacts) {
572         this.testArtifacts = testArtifacts;
573     }
574 
575     /**
576      * @param runtimeArtifacts
577      */
578     public void setRuntimeArtifacts(List<Artifact> runtimeArtifacts) {
579         this.runtimeArtifacts = runtimeArtifacts;
580     }
581 
582     /**
583      * @param runtimeDependencies
584      */
585     public void setRuntimeDependencies(List<Dependency> runtimeDependencies) {
586         this.runtimeDependencies = runtimeDependencies;
587     }
588 
589     /**
590      * @param model
591      */
592     @Override
593     public void setModel(Model model) {
594         this.model = model;
595     }
596 
597     /** {@inheritDoc} */
598     @Override
599     public List<Dependency> getSystemDependencies() {
600         return systemDependencies;
601     }
602 
603     /** {@inheritDoc} */
604     @Override
605     public void setModelVersion(String string) {
606         this.modelVersion = string;
607     }
608 
609     /** {@inheritDoc} */
610     @Override
611     public String getModelVersion() {
612         return modelVersion;
613     }
614 
615     /**
616      * By default, return an empty String.
617      *
618      * @see org.apache.maven.project.MavenProject#getId()
619      */
620     @Override
621     public String getId() {
622         return "";
623     }
624 
625     /** {@inheritDoc} */
626     @Override
627     public void setGroupId(String string) {
628         this.groupId = string;
629     }
630 
631     /** {@inheritDoc} */
632     @Override
633     public String getGroupId() {
634         return groupId;
635     }
636 
637     /** {@inheritDoc} */
638     @Override
639     public void setArtifactId(String string) {
640         this.artifactId = string;
641     }
642 
643     /** {@inheritDoc} */
644     @Override
645     public String getArtifactId() {
646         return artifactId;
647     }
648 
649     /** {@inheritDoc} */
650     @Override
651     public void setName(String string) {
652         this.name = string;
653     }
654 
655     /** {@inheritDoc} */
656     @Override
657     public String getName() {
658         return name;
659     }
660 
661     /** {@inheritDoc} */
662     @Override
663     public void setVersion(String string) {
664         this.version = string;
665     }
666 
667     /** {@inheritDoc} */
668     @Override
669     public String getVersion() {
670         return version;
671     }
672 
673     /** {@inheritDoc} */
674     @Override
675     public String getPackaging() {
676         return packaging;
677     }
678 
679     /** {@inheritDoc} */
680     @Override
681     public void setPackaging(String string) {
682         this.packaging = string;
683     }
684 
685     /** {@inheritDoc} */
686     @Override
687     public void setInceptionYear(String string) {
688         this.inceptionYear = string;
689     }
690 
691     /** {@inheritDoc} */
692     @Override
693     public String getInceptionYear() {
694         return inceptionYear;
695     }
696 
697     /** {@inheritDoc} */
698     @Override
699     public void setUrl(String string) {
700         this.url = string;
701     }
702 
703     /** {@inheritDoc} */
704     @Override
705     public String getUrl() {
706         return url;
707     }
708 
709     /**
710      * By default, return <code>null</code>.
711      *
712      * @see org.apache.maven.project.MavenProject#getPrerequisites()
713      */
714     @Override
715     public Prerequisites getPrerequisites() {
716         return null;
717     }
718 
719     /**
720      * By default, do nothing.
721      *
722      * @see org.apache.maven.project.MavenProject#setIssueManagement(org.apache.maven.model.IssueManagement)
723      */
724     @Override
725     public void setIssueManagement(IssueManagement issueManagement) {
726         // nop
727     }
728 
729     /**
730      * By default, return <code>null</code>.
731      *
732      * @see org.apache.maven.project.MavenProject#getCiManagement()
733      */
734     @Override
735     public CiManagement getCiManagement() {
736         return null;
737     }
738 
739     /**
740      * By default, do nothing.
741      *
742      * @see org.apache.maven.project.MavenProject#setCiManagement(org.apache.maven.model.CiManagement)
743      */
744     @Override
745     public void setCiManagement(CiManagement ciManagement) {
746         // nop
747     }
748 
749     /**
750      * By default, return <code>null</code>.
751      *
752      * @see org.apache.maven.project.MavenProject#getIssueManagement()
753      */
754     @Override
755     public IssueManagement getIssueManagement() {
756         return null;
757     }
758 
759     /**
760      * By default, do nothing.
761      *
762      * @see org.apache.maven.project.MavenProject#setDistributionManagement(org.apache.maven.model.DistributionManagement)
763      */
764     @Override
765     public void setDistributionManagement(DistributionManagement distributionManagement) {
766         // nop
767     }
768 
769     /**
770      * By default, return <code>null</code>.
771      *
772      * @see org.apache.maven.project.MavenProject#getDistributionManagement()
773      */
774     @Override
775     public DistributionManagement getDistributionManagement() {
776         return null;
777     }
778 
779     /** {@inheritDoc} */
780     @Override
781     public void setDescription(String string) {
782         this.description = string;
783     }
784 
785     /** {@inheritDoc} */
786     @Override
787     public String getDescription() {
788         return description;
789     }
790 
791     /**
792      * By default, do nothing.
793      *
794      * @see org.apache.maven.project.MavenProject#setOrganization(org.apache.maven.model.Organization)
795      */
796     @Override
797     public void setOrganization(Organization organization) {
798         // nop
799     }
800 
801     /**
802      * By default, return <code>null</code>.
803      *
804      * @see org.apache.maven.project.MavenProject#getOrganization()
805      */
806     @Override
807     public Organization getOrganization() {
808         return null;
809     }
810 
811     /**
812      * By default, do nothing.
813      *
814      * @see org.apache.maven.project.MavenProject#setScm(org.apache.maven.model.Scm)
815      */
816     @Override
817     public void setScm(Scm scm) {
818         // nop
819     }
820 
821     /**
822      * By default, return <code>null</code>.
823      *
824      * @see org.apache.maven.project.MavenProject#getScm()
825      */
826     @Override
827     public Scm getScm() {
828         return null;
829     }
830 
831     /**
832      * By default, do nothing.
833      *
834      * @see org.apache.maven.project.MavenProject#setMailingLists(java.util.List)
835      */
836     @Override
837     public void setMailingLists(List<MailingList> list) {
838         // nop
839     }
840 
841     /**
842      * By default, return <code>Collections.EMPTY_LIST</code>.
843      *
844      * @see org.apache.maven.project.MavenProject#getMailingLists()
845      */
846     @Override
847     public List<MailingList> getMailingLists() {
848         return Collections.<MailingList>emptyList();
849     }
850 
851     /**
852      * By default, do nothing.
853      *
854      * @see org.apache.maven.project.MavenProject#addMailingList(org.apache.maven.model.MailingList)
855      */
856     @Override
857     public void addMailingList(MailingList mailingList) {
858         // nop
859     }
860 
861     /**
862      * By default, do nothing.
863      *
864      * @see org.apache.maven.project.MavenProject#setDevelopers(java.util.List)
865      */
866     @Override
867     public void setDevelopers(List<Developer> list) {
868         // nop
869     }
870 
871     /**
872      * By default, return <code>Collections.EMPTY_LIST</code>.
873      *
874      * @see org.apache.maven.project.MavenProject#getDevelopers()
875      */
876     @Override
877     public List<Developer> getDevelopers() {
878         return Collections.<Developer>emptyList();
879     }
880 
881     /**
882      * By default, do nothing.
883      *
884      * @see org.apache.maven.project.MavenProject#addDeveloper(org.apache.maven.model.Developer)
885      */
886     @Override
887     public void addDeveloper(Developer developer) {
888         // nop
889     }
890 
891     /**
892      * By default, do nothing.
893      *
894      * @see org.apache.maven.project.MavenProject#setContributors(java.util.List)
895      */
896     @Override
897     public void setContributors(List<Contributor> list) {
898         // nop
899     }
900 
901     /**
902      * By default, return <code>Collections.EMPTY_LIST</code>.
903      *
904      * @see org.apache.maven.project.MavenProject#getContributors()
905      */
906     @Override
907     public List<Contributor> getContributors() {
908         return Collections.<Contributor>emptyList();
909     }
910 
911     /**
912      * By default, do nothing.
913      *
914      * @see org.apache.maven.project.MavenProject#addContributor(org.apache.maven.model.Contributor)
915      */
916     @Override
917     public void addContributor(Contributor contributor) {
918         // nop
919     }
920 
921     /** {@inheritDoc} */
922     @Override
923     public void setBuild(Build build) {
924         this.build = build;
925     }
926 
927     /** {@inheritDoc} */
928     @Override
929     public Build getBuild() {
930         return build;
931     }
932 
933     /**
934      * By default, return <code>Collections.EMPTY_LIST</code>.
935      *
936      * @see org.apache.maven.project.MavenProject#getResources()
937      */
938     @Override
939     public List<Resource> getResources() {
940         return Collections.<Resource>emptyList();
941     }
942 
943     /**
944      * By default, return <code>Collections.EMPTY_LIST</code>.
945      *
946      * @see org.apache.maven.project.MavenProject#getTestResources()
947      */
948     @Override
949     public List<Resource> getTestResources() {
950         return Collections.<Resource>emptyList();
951     }
952 
953     /**
954      * By default, do nothing.
955      *
956      * @see org.apache.maven.project.MavenProject#addResource(org.apache.maven.model.Resource)
957      */
958     @Override
959     public void addResource(Resource resource) {
960         // nop
961     }
962 
963     /**
964      * By default, do nothing.
965      *
966      * @see org.apache.maven.project.MavenProject#addTestResource(org.apache.maven.model.Resource)
967      */
968     @Override
969     public void addTestResource(Resource resource) {
970         // nop
971     }
972 
973     /**
974      * By default, do nothing.
975      *
976      * @see org.apache.maven.project.MavenProject#setReporting(org.apache.maven.model.Reporting)
977      */
978     @Override
979     public void setReporting(Reporting reporting) {
980         // nop
981     }
982 
983     /**
984      * By default, return <code>null</code>.
985      *
986      * @see org.apache.maven.project.MavenProject#getReporting()
987      */
988     @Override
989     public Reporting getReporting() {
990         return null;
991     }
992 
993     /** {@inheritDoc} */
994     @Override
995     public void setLicenses(List<License> licenses) {
996         this.licenses = licenses;
997     }
998 
999     /** {@inheritDoc} */
1000     @Override
1001     public List<License> getLicenses() {
1002         return licenses;
1003     }
1004 
1005     /**
1006      * By default, do nothing.
1007      *
1008      * @see org.apache.maven.project.MavenProject#addLicense(org.apache.maven.model.License)
1009      */
1010     @Override
1011     public void addLicense(License license) {
1012         // nop
1013     }
1014 
1015     /**
1016      * By default, do nothing.
1017      *
1018      * @see org.apache.maven.project.MavenProject#setArtifacts(java.util.Set)
1019      */
1020     @Override
1021     public void setArtifacts(Set<Artifact> set) {
1022         // nop
1023     }
1024 
1025     /**
1026      * By default, return <code>Collections.EMPTY_SET</code>.
1027      *
1028      * @see org.apache.maven.project.MavenProject#getArtifacts()
1029      */
1030     @Override
1031     public Set<Artifact> getArtifacts() {
1032         return Collections.<Artifact>emptySet();
1033     }
1034 
1035     /**
1036      * By default, return <code>Collections.EMPTY_MAP</code>.
1037      *
1038      * @see org.apache.maven.project.MavenProject#getArtifactMap()
1039      */
1040     @Override
1041     public Map<String, Artifact> getArtifactMap() {
1042         return Collections.<String, Artifact>emptyMap();
1043     }
1044 
1045     /**
1046      * By default, do nothing.
1047      *
1048      * @see org.apache.maven.project.MavenProject#setPluginArtifacts(java.util.Set)
1049      */
1050     @Override
1051     public void setPluginArtifacts(Set<Artifact> set) {
1052         // nop
1053     }
1054 
1055     /**
1056      * By default, return <code>Collections.EMPTY_SET</code>.
1057      *
1058      * @see org.apache.maven.project.MavenProject#getPluginArtifacts()
1059      */
1060     @Override
1061     public Set<Artifact> getPluginArtifacts() {
1062         return Collections.<Artifact>emptySet();
1063     }
1064 
1065     /**
1066      * By default, return <code>Collections.EMPTY_MAP</code>.
1067      *
1068      * @see org.apache.maven.project.MavenProject#getPluginArtifactMap()
1069      */
1070     @Override
1071     public Map<String, Artifact> getPluginArtifactMap() {
1072         return Collections.<String, Artifact>emptyMap();
1073     }
1074 
1075     /**
1076      * By default, do nothing.
1077      *
1078      * @see org.apache.maven.project.MavenProject#setReportArtifacts(java.util.Set)
1079      */
1080     @Override
1081     public void setReportArtifacts(Set<Artifact> set) {
1082         // nop
1083     }
1084 
1085     /**
1086      * By default, return <code>Collections.EMPTY_SET</code>.
1087      *
1088      * @see org.apache.maven.project.MavenProject#getReportArtifacts()
1089      */
1090     @Override
1091     public Set<Artifact> getReportArtifacts() {
1092         return Collections.<Artifact>emptySet();
1093     }
1094 
1095     /**
1096      * By default, return <code>Collections.EMPTY_MAP</code>.
1097      *
1098      * @see org.apache.maven.project.MavenProject#getReportArtifactMap()
1099      */
1100     @Override
1101     public Map<String, Artifact> getReportArtifactMap() {
1102         return Collections.<String, Artifact>emptyMap();
1103     }
1104 
1105     /**
1106      * By default, do nothing.
1107      *
1108      * @see org.apache.maven.project.MavenProject#setExtensionArtifacts(java.util.Set)
1109      */
1110     @Override
1111     public void setExtensionArtifacts(Set<Artifact> set) {
1112         // nop
1113     }
1114 
1115     /**
1116      * By default, return <code>Collections.EMPTY_SET</code>.
1117      *
1118      * @see org.apache.maven.project.MavenProject#getExtensionArtifacts()
1119      */
1120     @Override
1121     public Set<Artifact> getExtensionArtifacts() {
1122         return Collections.<Artifact>emptySet();
1123     }
1124 
1125     /**
1126      * By default, return <code>Collections.EMPTY_MAP</code>.
1127      *
1128      * @see org.apache.maven.project.MavenProject#getExtensionArtifactMap()
1129      */
1130     @Override
1131     public Map<String, Artifact> getExtensionArtifactMap() {
1132         return Collections.<String, Artifact>emptyMap();
1133     }
1134 
1135     /**
1136      * By default, do nothing.
1137      *
1138      * @see org.apache.maven.project.MavenProject#setParentArtifact(org.apache.maven.artifact.Artifact)
1139      */
1140     @Override
1141     public void setParentArtifact(Artifact artifact) {
1142         // nop
1143     }
1144 
1145     /**
1146      * By default, return <code>null</code>.
1147      *
1148      * @see org.apache.maven.project.MavenProject#getParentArtifact()
1149      */
1150     @Override
1151     public Artifact getParentArtifact() {
1152         return null;
1153     }
1154 
1155     /**
1156      * By default, return <code>Collections.EMPTY_LIST</code>.
1157      *
1158      * @see org.apache.maven.project.MavenProject#getRepositories()
1159      */
1160     @Override
1161     public List<Repository> getRepositories() {
1162         return Collections.<Repository>emptyList();
1163     }
1164 
1165     /**
1166      * By default, return <code>Collections.EMPTY_LIST</code>.
1167      *
1168      * @see org.apache.maven.project.MavenProject#getReportPlugins()
1169      */
1170     @Override
1171     public List<ReportPlugin> getReportPlugins() {
1172         return Collections.<ReportPlugin>emptyList();
1173     }
1174 
1175     /**
1176      * By default, return <code>Collections.EMPTY_LIST</code>.
1177      *
1178      * @see org.apache.maven.project.MavenProject#getBuildPlugins()
1179      */
1180     @Override
1181     public List<Plugin> getBuildPlugins() {
1182         return Collections.<Plugin>emptyList();
1183     }
1184 
1185     /**
1186      * By default, return <code>Collections.EMPTY_LIST</code>.
1187      *
1188      * @see org.apache.maven.project.MavenProject#getModules()
1189      */
1190     @Override
1191     public List<String> getModules() {
1192         return Collections.<String>emptyList();
1193     }
1194 
1195     /**
1196      * By default, return <code>null</code>.
1197      *
1198      * @see org.apache.maven.project.MavenProject#getPluginManagement()
1199      */
1200     @Override
1201     public PluginManagement getPluginManagement() {
1202         return null;
1203     }
1204 
1205     /**
1206      * By default, do nothing.
1207      */
1208     public void addPlugin(Plugin plugin) {
1209         // nop
1210     }
1211 
1212     /**
1213      * By default, do nothing.
1214      *
1215      * @param plugin
1216      */
1217     public void injectPluginManagementInfo(Plugin plugin) {
1218         // nop
1219     }
1220 
1221     /** {@inheritDoc} */
1222     @Override
1223     public List<MavenProject> getCollectedProjects() {
1224         return collectedProjects;
1225     }
1226 
1227     /** {@inheritDoc} */
1228     @Override
1229     public void setCollectedProjects(List<MavenProject> list) {
1230         this.collectedProjects = list;
1231     }
1232 
1233     /** {@inheritDoc} */
1234     @Override
1235     public void setPluginArtifactRepositories(List<ArtifactRepository> list) {
1236         this.pluginArtifactRepositories = list;
1237     }
1238 
1239     /** {@inheritDoc} */
1240     @Override
1241     public List<ArtifactRepository> getPluginArtifactRepositories() {
1242         return pluginArtifactRepositories;
1243     }
1244 
1245     /**
1246      * By default, return <code>null</code>.
1247      *
1248      * @see org.apache.maven.project.MavenProject#getDistributionManagementArtifactRepository()
1249      */
1250     @Override
1251     public ArtifactRepository getDistributionManagementArtifactRepository() {
1252         return null;
1253     }
1254 
1255     /**
1256      * By default, return <code>Collections.EMPTY_LIST</code>.
1257      *
1258      * @see org.apache.maven.project.MavenProject#getPluginRepositories()
1259      */
1260     @Override
1261     public List<Repository> getPluginRepositories() {
1262         return Collections.<Repository>emptyList();
1263     }
1264 
1265     /** {@inheritDoc} */
1266     @Override
1267     public void setActiveProfiles(List<Profile> list) {
1268         activeProfiles = list;
1269     }
1270 
1271     /** {@inheritDoc} */
1272     @Override
1273     public List<Profile> getActiveProfiles() {
1274         return activeProfiles;
1275     }
1276 
1277     /** {@inheritDoc} */
1278     @Override
1279     public void addAttachedArtifact(Artifact artifact) {
1280         if (attachedArtifacts == null) {
1281             this.attachedArtifacts = new ArrayList<>(Collections.singletonList(artifact));
1282         } else {
1283             attachedArtifacts.add(artifact);
1284         }
1285     }
1286 
1287     /** {@inheritDoc} */
1288     @Override
1289     public List<Artifact> getAttachedArtifacts() {
1290         return attachedArtifacts;
1291     }
1292 
1293     /**
1294      * By default, return <code>null</code>.
1295      *
1296      * @see org.apache.maven.project.MavenProject#getGoalConfiguration(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
1297      */
1298     @Override
1299     public Xpp3Dom getGoalConfiguration(String string, String string1, String string2, String string3) {
1300         return null;
1301     }
1302 
1303     /**
1304      * By default, return <code>null</code>.
1305      *
1306      * @see org.apache.maven.project.MavenProject#getReportConfiguration(java.lang.String, java.lang.String, java.lang.String)
1307      */
1308     @Override
1309     public Xpp3Dom getReportConfiguration(String string, String string1, String string2) {
1310         return null;
1311     }
1312 
1313     /**
1314      * By default, return <code>null</code>.
1315      *
1316      * @see org.apache.maven.project.MavenProject#getExecutionProject()
1317      */
1318     @Override
1319     public MavenProject getExecutionProject() {
1320         return null;
1321     }
1322 
1323     /**
1324      * By default, do nothing.
1325      *
1326      * @see org.apache.maven.project.MavenProject#setExecutionProject(org.apache.maven.project.MavenProject)
1327      */
1328     @Override
1329     public void setExecutionProject(MavenProject mavenProject) {
1330         // nop
1331     }
1332 
1333     /**
1334      * By default, do nothing.
1335      *
1336      * @see org.apache.maven.project.MavenProject#writeModel(java.io.Writer)
1337      */
1338     @Override
1339     public void writeModel(Writer writer) throws IOException {
1340         // nop
1341     }
1342 
1343     /**
1344      * By default, do nothing.
1345      *
1346      * @see org.apache.maven.project.MavenProject#writeOriginalModel(java.io.Writer)
1347      */
1348     @Override
1349     public void writeOriginalModel(Writer writer) throws IOException {
1350         // nop
1351     }
1352 
1353     /** {@inheritDoc} */
1354     @Override
1355     public Set<Artifact> getDependencyArtifacts() {
1356         return dependencyArtifacts;
1357     }
1358 
1359     /** {@inheritDoc} */
1360     @Override
1361     public void setDependencyArtifacts(Set<Artifact> set) {
1362         this.dependencyArtifacts = set;
1363     }
1364 
1365     /** {@inheritDoc} */
1366     @Override
1367     public void setReleaseArtifactRepository(ArtifactRepository artifactRepository) {
1368         this.releaseArtifactRepository = artifactRepository;
1369     }
1370 
1371     /** {@inheritDoc} */
1372     @Override
1373     public void setSnapshotArtifactRepository(ArtifactRepository artifactRepository) {
1374         this.snapshotArtifactRepository = artifactRepository;
1375     }
1376 
1377     /** {@inheritDoc} */
1378     @Override
1379     public void setOriginalModel(Model model) {
1380         this.originalModel = model;
1381     }
1382 
1383     /** {@inheritDoc} */
1384     @Override
1385     public Model getOriginalModel() {
1386         return originalModel;
1387     }
1388 
1389     /**
1390      * By default, return <code>Collections.EMPTY_LIST</code>.
1391      *
1392      * @see org.apache.maven.project.MavenProject#getBuildExtensions()
1393      */
1394     @Override
1395     public List<Extension> getBuildExtensions() {
1396         return Collections.<Extension>emptyList();
1397     }
1398 
1399     /**
1400      * By default, return <code>Collections.EMPTY_SET</code>.
1401      *
1402      * @see org.apache.maven.project.MavenProject#createArtifacts(org.apache.maven.artifact.factory.ArtifactFactory, java.lang.String, org.apache.maven.artifact.resolver.filter.ArtifactFilter)
1403      */
1404     @Override
1405     public Set<Artifact> createArtifacts(
1406             ArtifactFactory artifactFactory, String string, ArtifactFilter artifactFilter) {
1407         return Collections.<Artifact>emptySet();
1408     }
1409 
1410     /**
1411      * By default, do nothing.
1412      *
1413      * @see org.apache.maven.project.MavenProject#addProjectReference(org.apache.maven.project.MavenProject)
1414      */
1415     @Override
1416     public void addProjectReference(MavenProject mavenProject) {
1417         // nop
1418     }
1419 
1420     /**
1421      * By default, do nothing.
1422      *
1423      * @see org.apache.maven.project.MavenProject#attachArtifact(java.lang.String, java.lang.String, java.io.File)
1424      */
1425     @Override
1426     public void attachArtifact(String string, String string1, File file) {
1427         // nop
1428     }
1429 
1430     /**
1431      * By default, return a new instance of <code>Properties</code>.
1432      *
1433      * @see org.apache.maven.project.MavenProject#getProperties()
1434      */
1435     @Override
1436     public Properties getProperties() {
1437         return new Properties();
1438     }
1439 
1440     /**
1441      * By default, return <code>Collections.EMPTY_LIST</code>.
1442      *
1443      * @see org.apache.maven.project.MavenProject#getFilters()
1444      */
1445     @Override
1446     public List<String> getFilters() {
1447         return Collections.<String>emptyList();
1448     }
1449 
1450     /**
1451      * By default, return <code>Collections.EMPTY_MAP</code>.
1452      *
1453      * @see org.apache.maven.project.MavenProject#getProjectReferences()
1454      */
1455     @Override
1456     public Map<String, MavenProject> getProjectReferences() {
1457         return Collections.<String, MavenProject>emptyMap();
1458     }
1459 
1460     /** {@inheritDoc} */
1461     @Override
1462     public boolean isExecutionRoot() {
1463         return executionRoot;
1464     }
1465 
1466     /** {@inheritDoc} */
1467     @Override
1468     public void setExecutionRoot(boolean b) {
1469         this.executionRoot = b;
1470     }
1471 
1472     /** {@inheritDoc} */
1473     @Override
1474     public String getDefaultGoal() {
1475         return defaultGoal;
1476     }
1477 
1478     /**
1479      * By default, return <code>null</code>.
1480      *
1481      * @see org.apache.maven.project.MavenProject#replaceWithActiveArtifact(org.apache.maven.artifact.Artifact)
1482      */
1483     @Override
1484     public Artifact replaceWithActiveArtifact(Artifact artifact) {
1485         return null;
1486     }
1487 }