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