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.util.Collection;
22 import java.util.Collections;
23 import java.util.List;
24 import org.apache.maven.artifact.Artifact;
25 import org.apache.maven.artifact.DefaultArtifact;
26 import org.apache.maven.artifact.InvalidArtifactRTException;
27 import org.apache.maven.artifact.handler.ArtifactHandler;
28 import org.apache.maven.artifact.metadata.ArtifactMetadata;
29 import org.apache.maven.artifact.repository.ArtifactRepository;
30 import org.apache.maven.artifact.versioning.ArtifactVersion;
31 import org.apache.maven.artifact.versioning.VersionRange;
32
33
34
35
36
37
38 @Deprecated
39 public class AttachedArtifact extends DefaultArtifact {
40
41 private final Artifact parent;
42
43 public AttachedArtifact(Artifact parent, String type, String classifier, ArtifactHandler artifactHandler) {
44 super(
45 parent.getGroupId(),
46 parent.getArtifactId(),
47 parent.getVersionRange(),
48 parent.getScope(),
49 type,
50 classifier,
51 artifactHandler,
52 parent.isOptional());
53
54 setDependencyTrail(Collections.singletonList(parent.getId()));
55
56 this.parent = parent;
57
58 if (getId().equals(parent.getId())) {
59 throw new InvalidArtifactRTException(
60 parent.getGroupId(),
61 parent.getArtifactId(),
62 parent.getVersion(),
63 parent.getType(),
64 "An attached artifact must have a different ID" + " than its corresponding main artifact.");
65 }
66 }
67
68 public AttachedArtifact(Artifact parent, String type, ArtifactHandler artifactHandler) {
69 this(parent, type, null, artifactHandler);
70 }
71
72 public void setArtifactId(String artifactId) {
73 throw new UnsupportedOperationException(
74 "Cannot change the artifactId for an attached artifact." + " It is derived from the main artifact.");
75 }
76
77 public List<ArtifactVersion> getAvailableVersions() {
78 return parent.getAvailableVersions();
79 }
80
81 public void setAvailableVersions(List<ArtifactVersion> availableVersions) {
82 throw new UnsupportedOperationException("Cannot change the version information for an attached artifact."
83 + " It is derived from the main artifact.");
84 }
85
86 public String getBaseVersion() {
87 return parent.getBaseVersion();
88 }
89
90 public void setBaseVersion(String baseVersion) {
91 throw new UnsupportedOperationException("Cannot change the version information for an attached artifact."
92 + " It is derived from the main artifact.");
93 }
94
95 public String getDownloadUrl() {
96 return parent.getDownloadUrl();
97 }
98
99 public void setDownloadUrl(String downloadUrl) {
100 throw new UnsupportedOperationException("Cannot change the download information for an attached artifact."
101 + " It is derived from the main artifact.");
102 }
103
104 public void setGroupId(String groupId) {
105 throw new UnsupportedOperationException(
106 "Cannot change the groupId for an attached artifact." + " It is derived from the main artifact.");
107 }
108
109 public ArtifactRepository getRepository() {
110 return parent.getRepository();
111 }
112
113 public void setRepository(ArtifactRepository repository) {
114 throw new UnsupportedOperationException("Cannot change the repository information for an attached artifact."
115 + " It is derived from the main artifact.");
116 }
117
118 public String getScope() {
119 return parent.getScope();
120 }
121
122 public void setScope(String scope) {
123 throw new UnsupportedOperationException("Cannot change the scoping information for an attached artifact."
124 + " It is derived from the main artifact.");
125 }
126
127 public String getVersion() {
128 return parent.getVersion();
129 }
130
131 public void setVersion(String version) {
132 throw new UnsupportedOperationException("Cannot change the version information for an attached artifact."
133 + " It is derived from the main artifact.");
134 }
135
136 public VersionRange getVersionRange() {
137 return parent.getVersionRange();
138 }
139
140 public void setVersionRange(VersionRange range) {
141 throw new UnsupportedOperationException("Cannot change the version information for an attached artifact."
142 + " It is derived from the main artifact.");
143 }
144
145 public boolean isRelease() {
146 return parent.isRelease();
147 }
148
149 public void setRelease(boolean release) {
150 throw new UnsupportedOperationException("Cannot change the version information for an attached artifact."
151 + " It is derived from the main artifact.");
152 }
153
154 public boolean isSnapshot() {
155 return parent.isSnapshot();
156 }
157
158 public void addMetadata(ArtifactMetadata metadata) {
159
160
161 }
162
163 public Collection<ArtifactMetadata> getMetadataList() {
164 return Collections.emptyList();
165 }
166 }