View Javadoc

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