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