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