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  
24  import org.apache.maven.model.Build;
25  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
26  
27  /**
28   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
29   * @version $Id: FixJdk5MavenProjectStub.html 829392 2012-08-19 17:29:37Z hboutemy $
30   */
31  public class FixJdk5MavenProjectStub
32      extends MavenProjectStub
33  {
34      public FixJdk5MavenProjectStub()
35      {
36          readModel( new File( getBasedir(), "pom.xml" ) );
37  
38          addCompileSourceRoot( getBasedir().getAbsolutePath() + "/target/classes" );
39          addCompileSourceRoot( getBasedir().getAbsolutePath() + "/src/main/java" );
40  
41          Build build = new Build();
42          build.setDirectory( getBasedir().getAbsolutePath() + "/target" );
43          build.setSourceDirectory( getBasedir().getAbsolutePath() + "/src/main/java" );
44          build.setOutputDirectory( getBasedir().getAbsolutePath() + "/target/classes" );
45          build.setTestSourceDirectory( getBasedir().getAbsolutePath() + "/src/test/java" );
46          build.setTestOutputDirectory( getBasedir().getAbsolutePath() + "/target/test-classes" );
47          setBuild( build );
48      }
49  
50      /** {@inheritDoc} */
51      public String getArtifactId()
52      {
53          return getModel().getArtifactId();
54      }
55  
56      /** {@inheritDoc} */
57      public String getGroupId()
58      {
59          String groupId = getModel().getGroupId();
60  
61          if ( ( groupId == null ) && ( getModel().getParent() != null ) )
62          {
63              groupId = getModel().getParent().getGroupId();
64          }
65  
66          return groupId;
67      }
68  
69      /** {@inheritDoc} */
70      public String getVersion()
71      {
72          String version = getModel().getVersion();
73  
74          if ( ( version == null ) && ( getModel().getParent() != null ) )
75          {
76              version = getModel().getParent().getVersion();
77          }
78  
79          return version;
80      }
81  
82      /** {@inheritDoc} */
83      public String getPackaging()
84      {
85          return getModel().getPackaging();
86      }
87  
88      /** {@inheritDoc} */
89      public File getBasedir()
90      {
91          // Using unit test dir
92          return new File( super.getBasedir() + "/target/test/unit/fix-jdk5-test/" );
93      }
94  
95      /** {@inheritDoc} */
96      public File getFile()
97      {
98          return new File( getBasedir(), "pom.xml" );
99      }
100 }