1 package org.apache.maven.repository.internal;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.ArrayList;
24 import java.util.Collection;
25 import java.util.Date;
26
27 import org.apache.maven.artifact.repository.metadata.Metadata;
28 import org.eclipse.aether.artifact.Artifact;
29
30
31
32
33 abstract class MavenSnapshotMetadata
34 extends MavenMetadata
35 {
36 static final String SNAPSHOT = "SNAPSHOT";
37
38 protected final Collection<Artifact> artifacts = new ArrayList<>();
39
40 protected final boolean legacyFormat;
41
42 protected MavenSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat, Date timestamp )
43 {
44 super( metadata, file, timestamp );
45 this.legacyFormat = legacyFormat;
46 }
47
48 protected static Metadata createRepositoryMetadata( Artifact artifact, boolean legacyFormat )
49 {
50 Metadata metadata = new Metadata();
51 if ( !legacyFormat )
52 {
53 metadata.setModelVersion( "1.1.0" );
54 }
55 metadata.setGroupId( artifact.getGroupId() );
56 metadata.setArtifactId( artifact.getArtifactId() );
57 metadata.setVersion( artifact.getBaseVersion() );
58
59 return metadata;
60 }
61
62 public void bind( Artifact artifact )
63 {
64 artifacts.add( artifact );
65 }
66
67 public Object getKey()
68 {
69 return getGroupId() + ':' + getArtifactId() + ':' + getVersion();
70 }
71
72 public static Object getKey( Artifact artifact )
73 {
74 return artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getBaseVersion();
75 }
76
77 protected String getKey( String classifier, String extension )
78 {
79 return classifier + ':' + extension;
80 }
81
82 public String getGroupId()
83 {
84 return metadata.getGroupId();
85 }
86
87 public String getArtifactId()
88 {
89 return metadata.getArtifactId();
90 }
91
92 public String getVersion()
93 {
94 return metadata.getVersion();
95 }
96
97 public Nature getNature()
98 {
99 return Nature.SNAPSHOT;
100 }
101 }