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  import java.util.Set;
27  
28  import org.apache.maven.artifact.Artifact;
29  import org.apache.maven.artifact.factory.ArtifactFactory;
30  import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
31  import org.apache.maven.model.Build;
32  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
33  import org.apache.maven.project.MavenProject;
34  import org.apache.maven.project.artifact.InvalidDependencyVersionException;
35  
36  /**
37   * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
38   */
39  public class AggregateProject2TestMavenProjectStub
40      extends MavenProjectStub
41  {
42      private Build build;
43  
44      public AggregateProject2TestMavenProjectStub()
45      {
46          setGroupId( "aggregate.test" );
47          setArtifactId( "aggregate-test-project2" );
48          setVersion( "1.0-SNAPSHOT" );
49          setPackaging( "jar" );
50          setExecutionRoot( true );
51  
52          Artifact artifact = new JavadocPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() );
53          artifact.setArtifactHandler( new DefaultArtifactHandlerStub() );
54          setArtifact( artifact );
55  
56          build = new Build();
57          build.setFinalName( "aggregate-test-project2" );
58          build.setDirectory( super.getBasedir() + "/target/test/unit/aggregate-test/target" );
59  
60          String basedir = getBasedir().getAbsolutePath();
61          List compileSourceRoots = new ArrayList();
62          compileSourceRoots.add( basedir + "/aggregate/test/project2" );
63          setCompileSourceRoots( compileSourceRoots );
64      }
65  
66      /**
67       * @see org.apache.maven.project.MavenProject#getBuild()
68       */
69      public Build getBuild()
70      {
71          return build;
72      }
73  
74      /**
75       * @see org.apache.maven.project.MavenProject#setBuild(org.apache.maven.model.Build)
76       */
77      public void setBuild( Build build )
78      {
79          this.build = build;
80      }
81  
82      /**
83       * @see org.apache.maven.project.MavenProject#createArtifacts(org.apache.maven.artifact.factory.ArtifactFactory,
84       *      java.lang.String, org.apache.maven.artifact.resolver.filter.ArtifactFilter)
85       */
86      public Set createArtifacts( ArtifactFactory artifactFactory, String string, ArtifactFilter artifactFilter )
87          throws InvalidDependencyVersionException
88      {
89          return Collections.EMPTY_SET;
90      }
91  
92      /**
93       * @see org.apache.maven.plugin.testing.stubs.MavenProjectStub#getBasedir()
94       */
95      public File getBasedir()
96      {
97          return new File( super.getBasedir() + "/src/test/resources/unit/aggregate-test/project2" );
98      }
99  
100     /**
101      * @see org.apache.maven.plugin.testing.stubs.MavenProjectStub#getExecutionProject()
102      */
103     public MavenProject getExecutionProject()
104     {
105         return this;
106     }
107 }