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 Project007Stub
38      extends MavenProjectStub
39  {
40      private Build build;
41  
42      private List<Resource> resources;
43  
44      private List<Resource> testResources;
45  
46      public Project007Stub()
47      {
48          Model model;
49          try
50          {
51              model = readModelFromFile( new File( getBasedir(), "target/test-classes/unit/project-007/pom.xml" ) );
52              setModel( model );
53  
54              setGroupId( model.getGroupId() );
55              setArtifactId( model.getArtifactId() );
56              setVersion( model.getVersion() );
57              setName( model.getName() );
58              setUrl( model.getUrl() );
59              setPackaging( model.getPackaging() );
60  
61              Build build = new Build();
62              build.setFinalName( getArtifactId() + "-" + getVersion() );
63              build.setDirectory( getBasedir() + "/target/test/unit/project-007/target" );
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-007/src/main/java" );
69              setCompileSourceRoots( compileSourceRoots );
70  
71              List<String> testCompileSourceRoots = new ArrayList<String>();
72              testCompileSourceRoots.add( basedir + "/target/test-classes/unit/project-007/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 }