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