1 package org.apache.maven.artifact.repository.metadata;
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.ArtifactUtils;
24 import org.apache.maven.artifact.repository.ArtifactRepository;
25 import org.apache.maven.artifact.versioning.ArtifactVersion;
26 import org.apache.maven.artifact.versioning.Restriction;
27 import org.apache.maven.artifact.versioning.VersionRange;
28
29
30
31
32
33
34 public class ArtifactRepositoryMetadata
35 extends AbstractRepositoryMetadata
36 {
37 private Artifact artifact;
38
39 public ArtifactRepositoryMetadata( Artifact artifact )
40 {
41 this( artifact, null );
42 }
43
44 public ArtifactRepositoryMetadata( Artifact artifact,
45 Versioning versioning )
46 {
47 super( createMetadata( artifact, versioning ) );
48 this.artifact = artifact;
49 }
50
51 public boolean storedInGroupDirectory()
52 {
53 return false;
54 }
55
56 public boolean storedInArtifactVersionDirectory()
57 {
58 return false;
59 }
60
61 public String getGroupId()
62 {
63 return artifact.getGroupId();
64 }
65
66 public String getArtifactId()
67 {
68 return artifact.getArtifactId();
69 }
70
71 public String getBaseVersion()
72 {
73
74 return null;
75 }
76
77 public Object getKey()
78 {
79 return "artifact " + artifact.getGroupId() + ":" + artifact.getArtifactId();
80 }
81
82 public boolean isSnapshot()
83 {
84
85 return false;
86 }
87
88 public int getNature()
89 {
90 if ( artifact.getVersion() != null )
91 {
92 return artifact.isSnapshot() ? SNAPSHOT : RELEASE;
93 }
94
95 VersionRange range = artifact.getVersionRange();
96 if ( range != null )
97 {
98 for ( Restriction restriction : range.getRestrictions() )
99 {
100 if ( isSnapshot( restriction.getLowerBound() ) || isSnapshot( restriction.getUpperBound() ) )
101 {
102 return RELEASE_OR_SNAPSHOT;
103 }
104 }
105 }
106
107 return RELEASE;
108 }
109
110 private boolean isSnapshot( ArtifactVersion version )
111 {
112 return version != null && ArtifactUtils.isSnapshot( version.getQualifier() );
113 }
114
115 public ArtifactRepository getRepository()
116 {
117 return null;
118 }
119
120 public void setRepository( ArtifactRepository remoteRepository )
121 {
122
123
124
125
126
127 }
128
129 }