1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.repository.internal;
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.artifact.repository.metadata.Metadata;
27 import org.eclipse.aether.artifact.Artifact;
28
29
30
31
32 @Deprecated(since = "4.0.0")
33 abstract class MavenSnapshotMetadata extends MavenMetadata {
34 static final String SNAPSHOT = "SNAPSHOT";
35
36 protected final Collection<Artifact> artifacts = new ArrayList<>();
37
38 protected MavenSnapshotMetadata(Metadata metadata, Path path, Date timestamp) {
39 super(metadata, path, timestamp);
40 }
41
42 protected static Metadata createRepositoryMetadata(Artifact artifact) {
43 Metadata metadata = new Metadata();
44 metadata.setModelVersion("1.1.0");
45 metadata.setGroupId(artifact.getGroupId());
46 metadata.setArtifactId(artifact.getArtifactId());
47 metadata.setVersion(artifact.getBaseVersion());
48
49 return metadata;
50 }
51
52 public void bind(Artifact artifact) {
53 artifacts.add(artifact);
54 }
55
56 public Object getKey() {
57 return getGroupId() + ':' + getArtifactId() + ':' + getVersion();
58 }
59
60 public static Object getKey(Artifact artifact) {
61 return artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getBaseVersion();
62 }
63
64 protected String getKey(String classifier, String extension) {
65 return classifier + ':' + extension;
66 }
67
68 @Override
69 public String getGroupId() {
70 return metadata.getGroupId();
71 }
72
73 @Override
74 public String getArtifactId() {
75 return metadata.getArtifactId();
76 }
77
78 @Override
79 public String getVersion() {
80 return metadata.getVersion();
81 }
82
83 @Override
84 public Nature getNature() {
85 return Nature.SNAPSHOT;
86 }
87 }