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.war.stub;
20  
21  import java.io.File;
22  import java.util.HashSet;
23  import java.util.Properties;
24  import java.util.Set;
25  
26  import org.apache.maven.artifact.Artifact;
27  import org.apache.maven.model.Build;
28  import org.apache.maven.model.Organization;
29  import org.apache.maven.project.MavenProject;
30  
31  /**
32   * Stub
33   */
34  public class MavenProjectBasicStub extends MavenProject {
35      protected String testRootDir;
36  
37      protected Properties properties;
38  
39      public MavenProjectBasicStub() throws Exception {
40          super(new ModelStub());
41          properties = new Properties();
42      }
43  
44      public Set<Artifact> getArtifacts() {
45          return new HashSet<>();
46      }
47  
48      public String getName() {
49          return "Test Project ";
50      }
51  
52      public File getBasedir() {
53          // create an isolated environment
54          // see setupTestEnvironment for details
55          // return new File( testRootDir );
56          return null;
57      }
58  
59      public String getGroupId() {
60          return "org.apache.maven.plugin.test";
61      }
62  
63      public String getArtifactId() {
64          return "maven-war-plugin-test";
65      }
66  
67      public String getPackaging() {
68          return "jar";
69      }
70  
71      public String getVersion() {
72          return "0.0-Test";
73      }
74  
75      public void addProperty(String key, String value) {
76          properties.put(key, value);
77      }
78  
79      public Properties getProperties() {
80          return properties;
81      }
82  
83      public String getDescription() {
84          return "Test Description";
85      }
86  
87      public Organization getOrganization() {
88          return new Organization() {
89              public String getName() {
90                  return "Test Name";
91              }
92          };
93      }
94  
95      @Override
96      public Build getBuild() {
97          Build build = super.getBuild();
98  
99          build.setDirectory(System.getProperty("project.build.directory"));
100         build.setOutputDirectory(System.getProperty("project.build.outputDirectory"));
101 
102         return build;
103     }
104 
105     @Override
106     public MavenProject clone() {
107         return this;
108     }
109 }