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  
23  import org.apache.maven.artifact.handler.ArtifactHandler;
24  
25  public class JarArtifactStub extends AbstractArtifactStub {
26  
27      protected String groupId;
28  
29      protected String artifactId;
30  
31      protected String version;
32  
33      protected boolean optional = false;
34  
35      protected String scope;
36  
37      private File file;
38  
39      private ArtifactHandler artifactHandler;
40  
41      public JarArtifactStub(String basedir, ArtifactHandler artifactHandler) {
42          super(basedir);
43          this.artifactHandler = artifactHandler;
44      }
45  
46      public void setGroupId(String id) {
47          groupId = id;
48      }
49  
50      public String getGroupId() {
51          if (groupId != null) {
52              return groupId;
53          } else {
54              return "org.sample.jar";
55          }
56      }
57  
58      public String getType() {
59          return "jar";
60      }
61  
62      public void setArtifactId(String artifactId) {
63          this.artifactId = artifactId;
64      }
65  
66      public String getArtifactId() {
67          if (artifactId != null) {
68              return artifactId;
69          } else {
70              return "jarartifact";
71          }
72      }
73  
74      public String getVersion() {
75          if (version != null) {
76              return version;
77          } else {
78              return super.getVersion();
79          }
80      }
81  
82      public void setVersion(String version) {
83          this.version = version;
84      }
85  
86      public boolean isOptional() {
87          return optional;
88      }
89  
90      public void setOptional(boolean optional) {
91          this.optional = optional;
92      }
93  
94      public String getScope() {
95          if (scope != null) {
96              return scope;
97          } else {
98              return super.getScope();
99          }
100     }
101 
102     public void setScope(String scope) {
103         this.scope = scope;
104     }
105 
106     public File getFile() {
107         if (file == null) {
108             return new File(basedir, "/target/test-classes/unit/sample_wars/simple.jar");
109         }
110         return file;
111     }
112 
113     public void setFile(File file) {
114         this.file = file;
115     }
116 
117     public ArtifactHandler getArtifactHandler() {
118         return artifactHandler;
119     }
120 }