View Javadoc
1   package org.apache.maven.plugins.javadoc.stubs;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.util.ArrayList;
24  import java.util.Arrays;
25  import java.util.Collections;
26  import java.util.List;
27  import java.util.Set;
28  
29  import org.apache.maven.artifact.Artifact;
30  import org.apache.maven.model.Build;
31  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
32  import org.apache.maven.project.MavenProject;
33  
34  /**
35   * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
36   */
37  public class AggregateTestMavenProjectStub
38      extends MavenProjectStub
39  {
40      private Build build;
41  
42      public AggregateTestMavenProjectStub()
43      {
44          readModel( new File( getBasedir(), "aggregate-test-plugin-config.xml" ) );
45  
46          setGroupId( getModel().getGroupId() );
47          setArtifactId( getModel().getArtifactId() );
48          setVersion( getModel().getVersion() );
49          setName( getModel().getName() );
50          setUrl( getModel().getUrl() );
51          setPackaging( getModel().getPackaging() );
52          setExecutionRoot( true );
53  
54          build = new Build();
55          build.setFinalName( getModel().getArtifactId() );
56          build.setDirectory( super.getBasedir() + "/target/test/unit/aggregate-test/target" );
57  
58          List<String> compileSourceRoots = new ArrayList<>();
59          compileSourceRoots.add( getBasedir() + "/src/main/java" );
60          setCompileSourceRoots( compileSourceRoots );
61      }
62  
63      @Override
64      public Build getBuild()
65      {
66          return build;
67      }
68  
69      @Override
70      public void setBuild( Build build )
71      {
72          this.build = build;
73      }
74  
75      @Override
76      public File getBasedir()
77      {
78          return new File( super.getBasedir() + "/src/test/resources/unit/aggregate-test" );
79      }
80  
81      @Override
82      public MavenProject getExecutionProject()
83      {
84          return this;
85      }
86      
87      @Override
88      public List<String> getModules()
89      {
90          return Arrays.asList( "project1", "project2" );
91      }
92      
93      @Override
94      public Set<Artifact> getDependencyArtifacts()
95      {
96          return Collections.emptySet();
97      }
98  }