View Javadoc
1   package org.apache.maven.plugins.source.stubs;
2   
3   import static org.apache.maven.plugins.source.stubs.Project001Stub.readModelFromFile;
4   
5   import java.io.File;
6   import java.util.ArrayList;
7   import java.util.List;
8   
9   import org.apache.maven.model.Build;
10  import org.apache.maven.model.Model;
11  import org.apache.maven.model.Resource;
12  
13  /*
14   * Licensed to the Apache Software Foundation (ASF) under one
15   * or more contributor license agreements.  See the NOTICE file
16   * distributed with this work for additional information
17   * regarding copyright ownership.  The ASF licenses this file
18   * to you under the Apache License, Version 2.0 (the
19   * "License"); you may not use this file except in compliance
20   * with the License.  You may obtain a copy of the License at
21   *
22   *   http://www.apache.org/licenses/LICENSE-2.0
23   *
24   * Unless required by applicable law or agreed to in writing,
25   * software distributed under the License is distributed on an
26   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
27   * KIND, either express or implied.  See the License for the
28   * specific language governing permissions and limitations
29   * under the License.
30   */
31  
32  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
33  
34  /**
35   * @author <a href="mailto:oching@exist.com">Maria Odea Ching</a>
36   */
37  public class Project003Stub
38      extends MavenProjectStub
39  {
40      private Build build;
41  
42      private List<Resource> resources;
43  
44      private List<Resource> testResources;
45  
46      public Project003Stub()
47      {
48          Model model;
49  
50          try
51          {
52              model = readModelFromFile( new File( getBasedir(), "target/test-classes/unit/project-003/pom.xml" ) );
53              setModel( model );
54  
55              setGroupId( model.getGroupId() );
56              setArtifactId( model.getArtifactId() );
57              setVersion( model.getVersion() );
58              setName( model.getName() );
59              setUrl( model.getUrl() );
60              setPackaging( model.getPackaging() );
61  
62              Build build = new Build();
63              build.setFinalName( getArtifactId() + "-" + getVersion() );
64              build.setDirectory( getBasedir() + "/target/test/unit/project-003/target" );
65              setBuild( build );
66  
67              String basedir = getBasedir().getAbsolutePath();
68              List<String> compileSourceRoots = new ArrayList<String>();
69              compileSourceRoots.add( basedir + "/target/test-classes/unit/project-003/src/main/java" );
70              setCompileSourceRoots( compileSourceRoots );
71  
72              List<String> testCompileSourceRoots = new ArrayList<String>();
73              testCompileSourceRoots.add( basedir + "/target/test-classes/unit/project-003/src/test/java" );
74              setTestCompileSourceRoots( testCompileSourceRoots );
75  
76              setResources( model.getBuild().getResources() );
77              setTestResources( model.getBuild().getTestResources() );
78  
79              SourcePluginArtifactStub artifact =
80                  new SourcePluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging(), null );
81              artifact.setArtifactHandler( new DefaultArtifactHandlerStub() );
82              artifact.setType( "jar" );
83              artifact.setBaseVersion( "1.0-SNAPSHOT" );
84              setArtifact( artifact );
85  
86          }
87          catch ( Exception e )
88          {
89              e.printStackTrace();
90          }
91      }
92  
93      public Build getBuild()
94      {
95          return build;
96      }
97  
98      public void setBuild( Build build )
99      {
100         this.build = build;
101     }
102 
103     public List<Resource> getResources()
104     {
105         return resources;
106     }
107 
108     public void setResources( List<Resource> resources )
109     {
110         this.resources = resources;
111     }
112 
113     public List<Resource> getTestResources()
114     {
115         return testResources;
116     }
117 
118     public void setTestResources( List<Resource> testResources )
119     {
120         this.testResources = testResources;
121     }
122 
123 }