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:reto.weiss@axonivy.com">Reto Weiss</a>
35   */
36  public class AbstractAggregateMavenProjectStub extends MavenProjectStub {
37      private final String baseDir;
38      private final String[] projects;
39  
40      public AbstractAggregateMavenProjectStub(
41              String baseDir, String pomFileName, String targetDirectory, String... projects) {
42          this.baseDir = baseDir;
43          this.projects = projects;
44          readModel(new File(getBasedir(), pomFileName));
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  
53          setExecutionRoot(true);
54  
55          Build build = new Build();
56          build.setFinalName(getModel().getArtifactId());
57          build.setSourceDirectory(getBasedir() + "/src/main/java");
58          build.setDirectory(super.getBasedir() + targetDirectory);
59          setBuild(build);
60  
61          List<String> compileSourceRoots = new ArrayList<>();
62          setCompileSourceRoots(compileSourceRoots);
63      }
64  
65      @Override
66      public File getBasedir() {
67          return new File(super.getBasedir() + baseDir);
68      }
69  
70      @Override
71      public MavenProject getExecutionProject() {
72          return this;
73      }
74  
75      @Override
76      public List<String> getModules() {
77          return Arrays.asList(projects);
78      }
79  
80      @Override
81      public Set<Artifact> getDependencyArtifacts() {
82          return Collections.emptySet();
83      }
84  }