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 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   * @version $Id: HelpFileMavenProjectStub.html 829392 2012-08-19 17:29:37Z hboutemy $
37   */
38  public class HelpFileMavenProjectStub extends MavenProjectStub
39  {
40      private Build build;
41  
42      public HelpFileMavenProjectStub()
43      {
44          readModel( new File( getBasedir(), "pom.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          Build build = new Build();
54          build.setFinalName( getModel().getArtifactId() );
55          build.setSourceDirectory( getBasedir() + "/src/main/java" );
56          build.setDirectory( super.getBasedir() + "/target/test/unit/helpfile-test/target" );
57          Resource resource = new Resource();
58          resource.setDirectory( getBasedir() + "/src/main/resources" );
59          build.addResource( resource );
60  
61          build.setPlugins( getModel().getBuild().getPlugins() );
62          setBuild( build );
63  
64          List compileSourceRoots = new ArrayList();
65          compileSourceRoots.add( getBasedir() + "/src/main/java" );
66          setCompileSourceRoots( compileSourceRoots );
67      }
68  
69      /** {@inheritDoc} */
70      public Build getBuild()
71      {
72          return build;
73      }
74  
75      /** {@inheritDoc} */
76      public void setBuild( Build build )
77      {
78          this.build = build;
79      }
80  
81      /** {@inheritDoc} */
82      public File getBasedir()
83      {
84          return new File( super.getBasedir() + "/src/test/resources/unit/helpfile-test" );
85      }
86  
87      /** {@inheritDoc} */
88      public List getRemoteArtifactRepositories()
89      {
90          ArtifactRepository repository =
91              new DefaultArtifactRepository( "central", "http://repo1.maven.org/maven2",
92                                             new DefaultRepositoryLayout() );
93  
94          return Collections.singletonList( repository );
95      }
96  }