View Javadoc
1   package org.apache.maven.plugins.ejb.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 java.io.File;
23  import java.util.LinkedList;
24  import java.util.List;
25  
26  import org.apache.maven.artifact.Artifact;
27  import org.apache.maven.artifact.handler.ArtifactHandler;
28  import org.apache.maven.artifact.handler.DefaultArtifactHandler;
29  import org.apache.maven.artifact.metadata.ArtifactMetadata;
30  import org.apache.maven.artifact.repository.ArtifactRepository;
31  import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
32  import org.apache.maven.artifact.versioning.ArtifactVersion;
33  import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
34  import org.apache.maven.artifact.versioning.VersionRange;
35  
36  /**
37   * Stub
38   */
39  public class ArtifactStub
40      implements Artifact
41  {
42  
43      boolean hasClassifier;
44  
45      boolean resolved;
46  
47      boolean optional;
48  
49      boolean release;
50  
51      ArtifactHandler artifactHandler;
52  
53      File file;
54  
55      String baseVersion;
56  
57      String type;
58  
59      String classifier;
60  
61      String identifier;
62  
63      String dependencyConflictId;
64  
65      String downloadUrl;
66  
67      String selectedVersion;
68  
69      String artifactId;
70  
71      String groupId;
72  
73      String resolvedVersion;
74  
75      String scope;
76  
77      String version;
78  
79      VersionRange versionRange;
80  
81      public ArtifactStub()
82      {
83          type = "testtype";
84          scope = "testscope";
85          classifier = "testclassifier";
86          artifactHandler = new DefaultArtifactHandler();
87      }
88  
89      public void populate( MavenProjectBasicStub project )
90      {
91          groupId = project.getGroupId();
92          artifactId = project.getArtifactId();
93          version = project.getVersion();
94          versionRange = VersionRange.createFromVersion( version );
95      }
96  
97      public boolean hasClassifier()
98      {
99          return true;
100     }
101 
102     public String getBaseVersion()
103     {
104         return "Test Version";
105     }
106 
107     public void setBaseVersion( String version )
108     {
109         baseVersion = version;
110     }
111 
112     public void setFile( File _file )
113     {
114         file = _file;
115     }
116 
117     public File getFile()
118     {
119         return new File( "testfile" );
120     }
121 
122     public String getGroupId()
123     {
124         return groupId;
125     }
126 
127     public String getArtifactId()
128     {
129         return artifactId;
130     }
131 
132     public String getVersion()
133     {
134         return version;
135     }
136 
137     public void setVersion( String _version )
138     {
139         version = _version;
140     }
141 
142     public String getScope()
143     {
144         return scope;
145     }
146 
147     public String getType()
148     {
149         return type;
150     }
151 
152     public String getClassifier()
153     {
154         return classifier;
155     }
156 
157     public String getId()
158     {
159         return identifier;
160     }
161 
162     public String getDependencyConflictId()
163     {
164         return dependencyConflictId;
165     }
166 
167     public void addMetadata( ArtifactMetadata metadata )
168     {
169         // intentionally empty
170     }
171 
172     public List<ArtifactMetadata> getMetadataList()
173     {
174         return new LinkedList<ArtifactMetadata>();
175     }
176 
177     public void setRepository( ArtifactRepository remoteRepository )
178     {
179         // intentionally empty
180     }
181 
182     public ArtifactRepository getRepository()
183     {
184         return null;
185     }
186 
187     public void updateVersion( String version, ArtifactRepository localRepository )
188     {
189         //Intentionally empty.
190     }
191 
192     public String getDownloadUrl()
193     {
194         return downloadUrl;
195     }
196 
197     public void setDownloadUrl( String _downloadUrl )
198     {
199         downloadUrl = _downloadUrl;
200     }
201 
202     public ArtifactFilter getDependencyFilter()
203     {
204         return null;
205     }
206 
207     public void setDependencyFilter( ArtifactFilter artifactFilter )
208     {
209         //Intentionally empty.
210     }
211 
212     public ArtifactHandler getArtifactHandler()
213     {
214         return artifactHandler;
215     }
216 
217     public List<String> getDependencyTrail()
218     {
219         return new LinkedList<String>();
220     }
221 
222     public void setDependencyTrail( List<String> dependencyTrail )
223     {
224         //Intentionally empty.
225     }
226 
227     public void setScope( String _scope )
228     {
229         scope = _scope;
230     }
231 
232     public VersionRange getVersionRange()
233     {
234         return versionRange;
235     }
236 
237     public void setVersionRange( VersionRange newRange )
238     {
239         //Intentionally empty.
240     }
241 
242     public void selectVersion( String version )
243     {
244         selectedVersion = version;
245     }
246 
247     public void setGroupId( String _groupId )
248     {
249         groupId = _groupId;
250     }
251 
252     public void setArtifactId( String _artifactId )
253     {
254         artifactId = _artifactId;
255     }
256 
257     public boolean isSnapshot()
258     {
259         return true;
260     }
261 
262     public void setResolved( boolean _resolved )
263     {
264         resolved = _resolved;
265     }
266 
267     public boolean isResolved()
268     {
269         return true;
270     }
271 
272     public void setResolvedVersion( String version )
273     {
274         resolvedVersion = version;
275     }
276 
277     public void setArtifactHandler( ArtifactHandler handler )
278     {
279         //Intentionally empty.
280     }
281 
282     public boolean isRelease()
283     {
284         return true;
285     }
286 
287     public void setRelease( boolean _release )
288     {
289         release = _release;
290     }
291 
292     public List<ArtifactVersion>  getAvailableVersions()
293     {
294         return new LinkedList<ArtifactVersion>();
295     }
296 
297     public void setAvailableVersions( List<ArtifactVersion> versions )
298     {
299         //Intentionally empty.
300     }
301 
302     public boolean isOptional()
303     {
304         return true;
305     }
306 
307     public void setOptional( boolean _optional )
308     {
309         optional = _optional;
310     }
311 
312     public ArtifactVersion getSelectedVersion()
313         throws OverConstrainedVersionException
314     {
315         return null;
316     }
317 
318     public boolean isSelectedVersionKnown()
319         throws OverConstrainedVersionException
320     {
321         return true;
322     }
323 
324     public int compareTo( Artifact o )
325     {
326         // TODO Auto-generated method stub
327         return 0;
328     }
329 
330     public ArtifactMetadata getMetadata( Class<?> arg0 )
331     {
332         // TODO Auto-generated method stub
333         return null;
334     }
335 }