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.io.xpp3.MavenXpp3Reader;
28  
29  /**
30   * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
31   */
32  public class TestSourceDirMavenProjectStub extends JxrProjectStub {
33  
34      public TestSourceDirMavenProjectStub() {
35          MavenXpp3Reader pomReader = new MavenXpp3Reader();
36          Model model = null;
37  
38          try {
39              model = pomReader.read(new FileReader(
40                      getBasedir() + "/src/test/resources/unit/testsourcedir-test/testsourcedir-test-plugin-config.xml"));
41              setModel(model);
42          } catch (Exception ignored) {
43  
44          }
45  
46          setArtifactId(model.getArtifactId());
47          setGroupId(model.getGroupId());
48          setVersion(model.getVersion());
49          setPackaging(model.getPackaging());
50          setInceptionYear(model.getInceptionYear());
51  
52          String basedir = getBasedir().getAbsolutePath();
53          List<String> compileSourceRoots = new ArrayList<>();
54          compileSourceRoots.add(basedir + "/src/test/resources/unit/testsourcedir-test");
55          setCompileSourceRoots(compileSourceRoots);
56  
57          Artifact artifact = new JxrPluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging());
58          artifact.setArtifactHandler(new DefaultArtifactHandlerStub());
59          setArtifact(artifact);
60      }
61  }