1 package org.apache.maven.project.artifact;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.artifact.Artifact;
23 import org.apache.maven.artifact.handler.ArtifactHandler;
24 import org.apache.maven.artifact.metadata.ArtifactMetadata;
25 import org.apache.maven.artifact.repository.ArtifactRepository;
26 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
27 import org.apache.maven.artifact.versioning.ArtifactVersion;
28 import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
29 import org.apache.maven.artifact.versioning.VersionRange;
30 import org.apache.maven.project.MavenProject;
31
32 import java.io.File;
33 import java.util.Collection;
34 import java.util.List;
35
36
37
38
39
40
41
42
43
44 @Deprecated
45 public class ActiveProjectArtifact
46 implements Artifact
47 {
48 private final Artifact artifact;
49
50 private final MavenProject project;
51
52 public ActiveProjectArtifact( MavenProject project, Artifact artifact )
53 {
54 this.artifact = artifact;
55 this.project = project;
56
57 artifact.setFile( project.getArtifact().getFile() );
58 artifact.setResolved( true );
59 }
60
61
62 public File getFile()
63 {
64
65 return project.getArtifact().getFile();
66 }
67
68
69 public String getGroupId()
70 {
71 return artifact.getGroupId();
72 }
73
74
75 public String getArtifactId()
76 {
77 return artifact.getArtifactId();
78 }
79
80
81 public String getVersion()
82 {
83 return artifact.getVersion();
84 }
85
86
87 public void setVersion( String version )
88 {
89 artifact.setVersion( version );
90 }
91
92
93 public String getScope()
94 {
95 return artifact.getScope();
96 }
97
98
99 public String getType()
100 {
101 return artifact.getType();
102 }
103
104
105 public String getClassifier()
106 {
107 return artifact.getClassifier();
108 }
109
110
111 public boolean hasClassifier()
112 {
113 return artifact.hasClassifier();
114 }
115
116
117 public void setFile( File destination )
118 {
119 artifact.setFile( destination );
120 project.getArtifact().setFile( destination );
121 }
122
123
124 public String getBaseVersion()
125 {
126 return artifact.getBaseVersion();
127 }
128
129
130 public void setBaseVersion( String baseVersion )
131 {
132 artifact.setBaseVersion( baseVersion );
133 }
134
135
136 public String getId()
137 {
138 return artifact.getId();
139 }
140
141
142 public String getDependencyConflictId()
143 {
144 return artifact.getDependencyConflictId();
145 }
146
147
148 public void addMetadata( ArtifactMetadata metadata )
149 {
150 artifact.addMetadata( metadata );
151 }
152
153
154 public Collection<ArtifactMetadata> getMetadataList()
155 {
156 return artifact.getMetadataList();
157 }
158
159
160 public void setRepository( ArtifactRepository remoteRepository )
161 {
162 artifact.setRepository( remoteRepository );
163 }
164
165
166 public ArtifactRepository getRepository()
167 {
168 return artifact.getRepository();
169 }
170
171
172 public void updateVersion( String version, ArtifactRepository localRepository )
173 {
174 artifact.updateVersion( version, localRepository );
175 }
176
177
178 public String getDownloadUrl()
179 {
180 return artifact.getDownloadUrl();
181 }
182
183
184 public void setDownloadUrl( String downloadUrl )
185 {
186 artifact.setDownloadUrl( downloadUrl );
187 }
188
189
190 public ArtifactFilter getDependencyFilter()
191 {
192 return artifact.getDependencyFilter();
193 }
194
195
196 public void setDependencyFilter( ArtifactFilter artifactFilter )
197 {
198 artifact.setDependencyFilter( artifactFilter );
199 }
200
201
202 public ArtifactHandler getArtifactHandler()
203 {
204 return artifact.getArtifactHandler();
205 }
206
207
208 public List<String> getDependencyTrail()
209 {
210 return artifact.getDependencyTrail();
211 }
212
213
214 public void setDependencyTrail( List<String> dependencyTrail )
215 {
216 artifact.setDependencyTrail( dependencyTrail );
217 }
218
219
220 public void setScope( String scope )
221 {
222 artifact.setScope( scope );
223 }
224
225
226 public VersionRange getVersionRange()
227 {
228 return artifact.getVersionRange();
229 }
230
231
232 public void setVersionRange( VersionRange newRange )
233 {
234 artifact.setVersionRange( newRange );
235 }
236
237
238 public void selectVersion( String version )
239 {
240 artifact.selectVersion( version );
241 }
242
243
244 public void setGroupId( String groupId )
245 {
246 artifact.setGroupId( groupId );
247 }
248
249
250 public void setArtifactId( String artifactId )
251 {
252 artifact.setArtifactId( artifactId );
253 }
254
255
256 public boolean isSnapshot()
257 {
258 return artifact.isSnapshot();
259 }
260
261
262 public int compareTo( Artifact a )
263 {
264 return artifact.compareTo( a );
265 }
266
267
268 public void setResolved( boolean resolved )
269 {
270 artifact.setResolved( resolved );
271 }
272
273
274 public boolean isResolved()
275 {
276 return artifact.isResolved();
277 }
278
279
280 public void setResolvedVersion( String version )
281 {
282 artifact.setResolvedVersion( version );
283 }
284
285
286 public void setArtifactHandler( ArtifactHandler handler )
287 {
288 artifact.setArtifactHandler( handler );
289 }
290
291
292 public String toString()
293 {
294 return "active project artifact:\n\tartifact = " + artifact + ";\n\tproject: " + project;
295 }
296
297
298 public boolean isRelease()
299 {
300 return artifact.isRelease();
301 }
302
303
304 public void setRelease( boolean release )
305 {
306 artifact.setRelease( release );
307 }
308
309
310 public List<ArtifactVersion> getAvailableVersions()
311 {
312 return artifact.getAvailableVersions();
313 }
314
315
316 public void setAvailableVersions( List<ArtifactVersion> versions )
317 {
318 artifact.setAvailableVersions( versions );
319 }
320
321
322 public boolean isOptional()
323 {
324 return artifact.isOptional();
325 }
326
327
328 public ArtifactVersion getSelectedVersion()
329 throws OverConstrainedVersionException
330 {
331 return artifact.getSelectedVersion();
332 }
333
334
335 public boolean isSelectedVersionKnown()
336 throws OverConstrainedVersionException
337 {
338 return artifact.isSelectedVersionKnown();
339 }
340
341
342 public void setOptional( boolean optional )
343 {
344 artifact.setOptional( optional );
345 }
346
347
348 public int hashCode()
349 {
350 int result = 17;
351
352 result = 37 * result + getGroupId().hashCode();
353 result = 37 * result + getArtifactId().hashCode();
354 result = 37 * result + getType().hashCode();
355 if ( getVersion() != null )
356 {
357 result = 37 * result + getVersion().hashCode();
358 }
359 result = 37 * result + ( getClassifier() != null ? getClassifier().hashCode() : 0 );
360
361 return result;
362 }
363
364
365 public boolean equals( Object o )
366 {
367 if ( o == this )
368 {
369 return true;
370 }
371
372 if ( !( o instanceof Artifact ) )
373 {
374 return false;
375 }
376
377 Artifact a = (Artifact) o;
378
379 if ( !a.getGroupId().equals( getGroupId() ) )
380 {
381 return false;
382 }
383 else if ( !a.getArtifactId().equals( getArtifactId() ) )
384 {
385 return false;
386 }
387 else if ( !a.getVersion().equals( getVersion() ) )
388 {
389 return false;
390 }
391 else if ( !a.getType().equals( getType() ) )
392 {
393 return false;
394 }
395 else if ( a.getClassifier() == null ? getClassifier() != null : !a.getClassifier().equals( getClassifier() ) )
396 {
397 return false;
398 }
399
400 return true;
401 }
402
403 }