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