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.jxr.stubs;
20  
21  import java.io.FileReader;
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  import org.apache.maven.artifact.Artifact;
26  import org.apache.maven.model.Model;
27  import org.apache.maven.model.ReportPlugin;
28  import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
29  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
30  
31  /**
32   * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
33   */
34  public class NoJavadocLinkConfigurationMavenProjectStub extends MavenProjectStub {
35      List<ReportPlugin> reportPlugins;
36  
37      public NoJavadocLinkConfigurationMavenProjectStub() {
38          MavenXpp3Reader pomReader = new MavenXpp3Reader();
39          Model model = null;
40  
41          try {
42              model = pomReader.read(
43                      new FileReader(
44                              getBasedir()
45                                      + "/src/test/resources/unit/nojavadoclink-configuration/nojavadoclink-configuration-plugin-config.xml"));
46              setModel(model);
47          } catch (Exception ignored) {
48  
49          }
50  
51          setArtifactId(model.getArtifactId());
52          setGroupId(model.getGroupId());
53          setVersion(model.getVersion());
54          setPackaging(model.getPackaging());
55          setInceptionYear(model.getInceptionYear());
56  
57          String basedir = getBasedir().getAbsolutePath();
58          List<String> compileSourceRoots = new ArrayList<>();
59          compileSourceRoots.add(
60                  basedir + "/src/test/resources/unit/nojavadoclink-configuration/nojavadoclink/configuration");
61          setCompileSourceRoots(compileSourceRoots);
62  
63          // set the report plugins
64          reportPlugins = new ArrayList<>(model.getReporting().getPlugins());
65  
66          Artifact artifact = new JxrPluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging());
67          artifact.setArtifactHandler(new DefaultArtifactHandlerStub());
68          setArtifact(artifact);
69      }
70  
71      @Override
72      public List<ReportPlugin> getReportPlugins() {
73          return reportPlugins;
74      }
75  }