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.plugins.javadoc.stubs;
20  
21  import java.io.File;
22  import java.util.ArrayList;
23  import java.util.Arrays;
24  import java.util.Collections;
25  import java.util.List;
26  import java.util.Set;
27  
28  import org.apache.maven.artifact.Artifact;
29  import org.apache.maven.model.Build;
30  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
31  import org.apache.maven.project.MavenProject;
32  
33  /**
34   * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
35   */
36  public class AggregateTestMavenProjectStub extends MavenProjectStub {
37      private Build build;
38  
39      public AggregateTestMavenProjectStub() {
40          readModel(new File(getBasedir(), "aggregate-test-plugin-config.xml"));
41  
42          setGroupId(getModel().getGroupId());
43          setArtifactId(getModel().getArtifactId());
44          setVersion(getModel().getVersion());
45          setName(getModel().getName());
46          setUrl(getModel().getUrl());
47          setPackaging(getModel().getPackaging());
48          setExecutionRoot(true);
49  
50          build = new Build();
51          build.setFinalName(getModel().getArtifactId());
52          build.setDirectory(super.getBasedir() + "/target/test/unit/aggregate-test/target");
53  
54          List<String> compileSourceRoots = new ArrayList<>();
55          compileSourceRoots.add(getBasedir() + "/src/main/java");
56          setCompileSourceRoots(compileSourceRoots);
57      }
58  
59      @Override
60      public Build getBuild() {
61          return build;
62      }
63  
64      @Override
65      public void setBuild(Build build) {
66          this.build = build;
67      }
68  
69      @Override
70      public File getBasedir() {
71          return new File(super.getBasedir() + "/src/test/resources/unit/aggregate-test");
72      }
73  
74      @Override
75      public MavenProject getExecutionProject() {
76          return this;
77      }
78  
79      @Override
80      public List<String> getModules() {
81          return Arrays.asList("project1", "project2");
82      }
83  
84      @Override
85      public Set<Artifact> getDependencyArtifacts() {
86          return Collections.emptySet();
87      }
88  }