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