1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.internal.impl.resolver;
20
21 import java.nio.file.Path;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.Date;
25
26 import org.apache.maven.api.metadata.Metadata;
27 import org.eclipse.aether.artifact.Artifact;
28
29
30
31 abstract class MavenSnapshotMetadata extends MavenMetadata {
32 static final String SNAPSHOT = "SNAPSHOT";
33
34 protected final Collection<Artifact> artifacts = new ArrayList<>();
35
36 protected MavenSnapshotMetadata(Metadata metadata, Path path, Date timestamp) {
37 super(metadata, path, timestamp);
38 }
39
40 protected static Metadata createRepositoryMetadata(Artifact artifact) {
41 return Metadata.newBuilder()
42 .modelVersion("1.1.0")
43 .groupId(artifact.getGroupId())
44 .artifactId(artifact.getArtifactId())
45 .version(artifact.getBaseVersion())
46 .build();
47 }
48
49 public void bind(Artifact artifact) {
50 artifacts.add(artifact);
51 }
52
53 public Object getKey() {
54 return getGroupId() + ':' + getArtifactId() + ':' + getVersion();
55 }
56
57 public static Object getKey(Artifact artifact) {
58 return artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getBaseVersion();
59 }
60
61 protected String getKey(String classifier, String extension) {
62 return classifier + ':' + extension;
63 }
64
65 @Override
66 public String getGroupId() {
67 return metadata.getGroupId();
68 }
69
70 @Override
71 public String getArtifactId() {
72 return metadata.getArtifactId();
73 }
74
75 @Override
76 public String getVersion() {
77 return metadata.getVersion();
78 }
79
80 @Override
81 public Nature getNature() {
82 return Nature.SNAPSHOT;
83 }
84 }