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.artifact.repository.ArtifactRepository;
23  import org.apache.maven.artifact.repository.DefaultArtifactRepository;
24  import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
25  import org.apache.maven.model.Build;
26  import org.apache.maven.model.Resource;
27  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
28  
29  import java.io.File;
30  import java.util.ArrayList;
31  import java.util.Collections;
32  import java.util.List;
33  
34  /**
35   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
36   */
37  public class HelpFileMavenProjectStub extends MavenProjectStub
38  {
39      public HelpFileMavenProjectStub()
40      {
41          readModel( new File( getBasedir(), "pom.xml" ) );
42  
43          setGroupId( getModel().getGroupId() );
44          setArtifactId( getModel().getArtifactId() );
45          setVersion( getModel().getVersion() );
46          setName( getModel().getName() );
47          setUrl( getModel().getUrl() );
48          setPackaging( getModel().getPackaging() );
49  
50          Build build = new Build();
51          build.setFinalName( getModel().getArtifactId() );
52          build.setSourceDirectory( getBasedir() + "/src/main/java" );
53          build.setDirectory( super.getBasedir() + "/target/test/unit/helpfile-test/target" );
54          Resource resource = new Resource();
55          resource.setDirectory( getBasedir() + "/src/main/resources" );
56          build.addResource( resource );
57  
58          build.setPlugins( getModel().getBuild().getPlugins() );
59          setBuild( build );
60  
61          List<String> compileSourceRoots = new ArrayList<>();
62          compileSourceRoots.add( getBasedir() + "/src/main/java" );
63          setCompileSourceRoots( compileSourceRoots );
64      }
65  
66      /** {@inheritDoc} */
67      @Override
68      public File getBasedir()
69      {
70          return new File( super.getBasedir() + "/src/test/resources/unit/helpfile-test" );
71      }
72  
73      /** {@inheritDoc} */
74      @Override
75      public List<ArtifactRepository> getRemoteArtifactRepositories()
76      {
77          ArtifactRepository repository =
78              new DefaultArtifactRepository( "central", "http://repo.maven.apache.org/maven2",
79                                             new DefaultRepositoryLayout() );
80  
81          return Collections.singletonList( repository );
82      }
83  }