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