View Javadoc

1   package org.apache.maven.plugin.javadoc.stubs;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.util.ArrayList;
24  import java.util.Collections;
25  import java.util.List;
26  
27  import org.apache.maven.artifact.Artifact;
28  import org.apache.maven.artifact.DefaultArtifact;
29  import org.apache.maven.artifact.handler.DefaultArtifactHandler;
30  import org.apache.maven.artifact.versioning.VersionRange;
31  import org.apache.maven.model.Build;
32  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
33  import org.apache.maven.project.MavenProject;
34  
35  /**
36   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
37   * @version $Id: TestJavadocMavenProjectStub.html 867202 2013-06-24 11:56:53Z olamy $
38   */
39  public class TestJavadocMavenProjectStub
40      extends MavenProjectStub
41  {
42      public TestJavadocMavenProjectStub()
43      {
44          readModel( new File( getBasedir(), "test-javadoc-test-plugin-config.xml" ) );
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          Artifact junit = new DefaultArtifact( "junit", "junit", VersionRange.createFromVersion( "3.8.1" ),
54                                                Artifact.SCOPE_TEST, "jar", null, new DefaultArtifactHandler( "jar" ),
55                                                false );
56          junit.setFile( new File( getBasedir() + "/junit/junit/3.8.1/junit-3.8.1.jar" ) );
57          setTestArtifacts( Collections.singletonList( junit ) );
58  
59          Build build = new Build();
60          build.setFinalName( getModel().getArtifactId() );
61          build.setDirectory( super.getBasedir() + "/target/test/unit/test-javadoc-test/target" );
62          build.setSourceDirectory( getBasedir() + "/src/main/java" );
63          build.setOutputDirectory( super.getBasedir() + "/target/test/unit/test-javadoc-test/target/classes" );
64          build.setTestSourceDirectory( getBasedir() + "/src/test/java" );
65          build.setTestOutputDirectory( super.getBasedir() + "/target/test/unit/test-javadoc-test/target/test-classes" );
66          setBuild( build );
67  
68          List<String> compileSourceRoots = new ArrayList<String>();
69          compileSourceRoots.add( getBasedir() + "/src/main/java" );
70          setCompileSourceRoots( compileSourceRoots );
71  
72          List<String> testCompileSourceRoots = new ArrayList<String>();
73          testCompileSourceRoots.add( getBasedir() + "/src/test/java" );
74          setTestCompileSourceRoots( testCompileSourceRoots );
75      }
76  
77      /** {@inheritDoc} */
78      public File getBasedir()
79      {
80          return new File( super.getBasedir() + "/src/test/resources/unit/test-javadoc-test" );
81      }
82  
83      /** {@inheritDoc} */
84      public MavenProject getExecutionProject()
85      {
86          return this;
87      }
88  }