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  
30  /**
31   * @author <a href="mailto:dennisl@apache.org">Dennis Lundberg</a>
32   */
33  public class ExcludeConfigurationMavenProjectStub extends JxrProjectStub {
34      private List<ReportPlugin> reportPlugins = new ArrayList<>();
35  
36      public ExcludeConfigurationMavenProjectStub() {
37          MavenXpp3Reader pomReader = new MavenXpp3Reader();
38          Model model = null;
39  
40          try {
41              model = pomReader.read(new FileReader(getBasedir()
42                      + "/src/test/resources/unit/exclude-configuration/exclude-configuration-plugin-config.xml"));
43              setModel(model);
44          } catch (Exception ignored) {
45  
46          }
47  
48          setArtifactId(model.getArtifactId());
49          setGroupId(model.getGroupId());
50          setVersion(model.getVersion());
51          setPackaging(model.getPackaging());
52          setInceptionYear(model.getInceptionYear());
53  
54          String basedir = getBasedir().getAbsolutePath();
55          List<String> compileSourceRoots = new ArrayList<>();
56          compileSourceRoots.add(basedir + "/src/test/resources/unit/exclude-configuration/exclude/configuration");
57          setCompileSourceRoots(compileSourceRoots);
58  
59          // set the report plugins
60          reportPlugins = new ArrayList<>(model.getReporting().getPlugins());
61  
62          Artifact artifact = new JxrPluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging());
63          artifact.setArtifactHandler(new DefaultArtifactHandlerStub());
64          setArtifact(artifact);
65      }
66  
67      @Override
68      public List<ReportPlugin> getReportPlugins() {
69          return reportPlugins;
70      }
71  }