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