View Javadoc
1   package org.apache.maven.plugins.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 org.apache.maven.model.Build;
23  import org.apache.maven.model.Scm;
24  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
25  
26  import java.io.File;
27  import java.util.ArrayList;
28  import java.util.List;
29  
30  /**
31   * Project stub for testing archive configuration.
32   */
33  public class JavadocJarArchiveConfigProjectStub
34      extends MavenProjectStub
35  {
36      private Scm scm;
37  
38      public JavadocJarArchiveConfigProjectStub()
39      {
40          File projectFile = new File( getBasedir(), "javadocjar-archive-config.xml" );
41          readModel( new File( getBasedir(), "javadocjar-archive-config.xml" ) );
42  
43          setFile( projectFile );
44  
45          setGroupId( getModel().getGroupId() );
46          setArtifactId( getModel().getArtifactId() );
47          setVersion( getModel().getVersion() );
48          setName( getModel().getName() );
49          setUrl( getModel().getUrl() );
50          setPackaging( getModel().getPackaging() );
51  
52          Scm scm = new Scm();
53          scm.setConnection( "scm:svn:http://svn.apache.org/maven/sample/trunk" );
54          setScm( scm );
55  
56          JavadocPluginArtifactStub artifact =
57                  new JavadocPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() );
58          artifact.setArtifactHandler( new DefaultArtifactHandlerStub() );
59          artifact.setType( "jar" );
60          artifact.setBaseVersion( "1.0-SNAPSHOT" );
61          setArtifact( artifact );
62  
63          Build build = new Build();
64          build.setFinalName( "javadocjar-archive-config" );
65          build.setDirectory( super.getBasedir() + "/target/test/unit/javadocjar-archive-config/target" );
66          setBuild( build );
67  
68          List<String> compileSourceRoots = new ArrayList<>();
69          compileSourceRoots.add( getBasedir().getAbsolutePath() );
70          setCompileSourceRoots( compileSourceRoots );
71      }
72  
73      /**
74       * {@inheritDoc}
75       */
76      @Override
77      public Scm getScm()
78      {
79          return scm;
80      }
81  
82      /**
83       * {@inheritDoc}
84       */
85      @Override
86      public void setScm(Scm scm)
87      {
88          this.scm = scm;
89      }
90  
91      /**
92       * {@inheritDoc}
93       */
94      @Override
95      public File getBasedir()
96      {
97          return new File( super.getBasedir() + "/src/test/resources/unit/javadocjar-archive-config" );
98      }
99  }