View Javadoc

1   package org.apache.maven.plugin.source.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 org.apache.maven.plugin.testing.stubs.MavenProjectStub;
23  import org.apache.maven.model.Build;
24  import org.apache.maven.model.Model;
25  import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
26  import org.apache.maven.artifact.Artifact;
27  import org.codehaus.plexus.util.ReaderFactory;
28  
29  import java.util.List;
30  import java.io.File;
31  
32  /**
33   * @author <a href="mailto:oching@exist.com">Maria Odea Ching</a>
34   */
35  public class Project005Stub
36      extends MavenProjectStub
37  {
38      private Build build;
39  
40      private List resources;
41  
42      private List testResources;
43  
44      public Project005Stub()
45      {
46          MavenXpp3Reader pomReader = new MavenXpp3Reader();
47          Model model;
48  
49          try
50          {
51              model = pomReader.read(
52                  ReaderFactory.newXmlReader( new File( getBasedir(), "target/test-classes/unit/project-005/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-005/target" );
65              setBuild( build );
66  
67              SourcePluginArtifactStub artifact =
68                  new SourcePluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging(), null );
69              artifact.setArtifactHandler( new DefaultArtifactHandlerStub() );
70              artifact.setType( "jar" );
71              artifact.setBaseVersion( "1.0-SNAPSHOT" );
72              setArtifact( artifact );
73  
74          }
75          catch ( Exception e )
76          {
77              e.printStackTrace();
78          }
79      }
80  
81      public Build getBuild()
82      {
83          return build;
84      }
85  
86      public void setBuild( Build build )
87      {
88          this.build = build;
89      }
90  
91      public List getResources()
92      {
93          return resources;
94      }
95  
96      public void setResources( List resources )
97      {
98          this.resources = resources;
99      }
100 
101     public List getTestResources()
102     {
103         return testResources;
104     }
105 
106     public void setTestResources( List testResources )
107     {
108         this.testResources = testResources;
109     }
110 
111 }