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