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