mirror of https://github.com/apache/maven.git
[MNG-7548] Kill off "legacy" repository metadata support (#1138)
This commit is contained in:
parent
ea1a280714
commit
124033bc04
|
@ -38,19 +38,15 @@ final class LocalSnapshotMetadata extends MavenMetadata {
|
|||
|
||||
private final Collection<Artifact> artifacts = new ArrayList<>();
|
||||
|
||||
private final boolean legacyFormat;
|
||||
|
||||
LocalSnapshotMetadata(Artifact artifact, boolean legacyFormat, Date timestamp) {
|
||||
super(createMetadata(artifact, legacyFormat), null, timestamp);
|
||||
this.legacyFormat = legacyFormat;
|
||||
LocalSnapshotMetadata(Artifact artifact, Date timestamp) {
|
||||
super(createMetadata(artifact), null, timestamp);
|
||||
}
|
||||
|
||||
LocalSnapshotMetadata(Metadata metadata, File file, boolean legacyFormat, Date timestamp) {
|
||||
LocalSnapshotMetadata(Metadata metadata, File file, Date timestamp) {
|
||||
super(metadata, file, timestamp);
|
||||
this.legacyFormat = legacyFormat;
|
||||
}
|
||||
|
||||
private static Metadata createMetadata(Artifact artifact, boolean legacyFormat) {
|
||||
private static Metadata createMetadata(Artifact artifact) {
|
||||
Snapshot snapshot = new Snapshot();
|
||||
snapshot.setLocalCopy(true);
|
||||
Versioning versioning = new Versioning();
|
||||
|
@ -61,11 +57,7 @@ final class LocalSnapshotMetadata extends MavenMetadata {
|
|||
metadata.setGroupId(artifact.getGroupId());
|
||||
metadata.setArtifactId(artifact.getArtifactId());
|
||||
metadata.setVersion(artifact.getBaseVersion());
|
||||
|
||||
if (!legacyFormat) {
|
||||
metadata.setModelVersion("1.1.0");
|
||||
}
|
||||
|
||||
metadata.setModelVersion("1.1.0");
|
||||
return metadata;
|
||||
}
|
||||
|
||||
|
@ -74,7 +66,7 @@ final class LocalSnapshotMetadata extends MavenMetadata {
|
|||
}
|
||||
|
||||
public MavenMetadata setFile(File file) {
|
||||
return new LocalSnapshotMetadata(metadata, file, legacyFormat, timestamp);
|
||||
return new LocalSnapshotMetadata(metadata, file, timestamp);
|
||||
}
|
||||
|
||||
public Object getKey() {
|
||||
|
@ -89,33 +81,31 @@ final class LocalSnapshotMetadata extends MavenMetadata {
|
|||
protected void merge(Metadata recessive) {
|
||||
metadata.getVersioning().setLastUpdatedTimestamp(timestamp);
|
||||
|
||||
if (!legacyFormat) {
|
||||
String lastUpdated = metadata.getVersioning().getLastUpdated();
|
||||
String lastUpdated = metadata.getVersioning().getLastUpdated();
|
||||
|
||||
Map<String, SnapshotVersion> versions = new LinkedHashMap<>();
|
||||
Map<String, SnapshotVersion> versions = new LinkedHashMap<>();
|
||||
|
||||
for (Artifact artifact : artifacts) {
|
||||
SnapshotVersion sv = new SnapshotVersion();
|
||||
sv.setClassifier(artifact.getClassifier());
|
||||
sv.setExtension(artifact.getExtension());
|
||||
sv.setVersion(getVersion());
|
||||
sv.setUpdated(lastUpdated);
|
||||
versions.put(getKey(sv.getClassifier(), sv.getExtension()), sv);
|
||||
}
|
||||
for (Artifact artifact : artifacts) {
|
||||
SnapshotVersion sv = new SnapshotVersion();
|
||||
sv.setClassifier(artifact.getClassifier());
|
||||
sv.setExtension(artifact.getExtension());
|
||||
sv.setVersion(getVersion());
|
||||
sv.setUpdated(lastUpdated);
|
||||
versions.put(getKey(sv.getClassifier(), sv.getExtension()), sv);
|
||||
}
|
||||
|
||||
Versioning versioning = recessive.getVersioning();
|
||||
if (versioning != null) {
|
||||
for (SnapshotVersion sv : versioning.getSnapshotVersions()) {
|
||||
String key = getKey(sv.getClassifier(), sv.getExtension());
|
||||
if (!versions.containsKey(key)) {
|
||||
versions.put(key, sv);
|
||||
}
|
||||
Versioning versioning = recessive.getVersioning();
|
||||
if (versioning != null) {
|
||||
for (SnapshotVersion sv : versioning.getSnapshotVersions()) {
|
||||
String key = getKey(sv.getClassifier(), sv.getExtension());
|
||||
if (!versions.containsKey(key)) {
|
||||
versions.put(key, sv);
|
||||
}
|
||||
}
|
||||
|
||||
metadata.getVersioning().setSnapshotVersions(new ArrayList<>(versions.values()));
|
||||
}
|
||||
|
||||
metadata.getVersioning().setSnapshotVersions(new ArrayList<>(versions.values()));
|
||||
|
||||
artifacts.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -40,13 +40,9 @@ class LocalSnapshotMetadataGenerator implements MetadataGenerator {
|
|||
|
||||
private Map<Object, LocalSnapshotMetadata> snapshots;
|
||||
|
||||
private final boolean legacyFormat;
|
||||
|
||||
private final Date timestamp;
|
||||
|
||||
LocalSnapshotMetadataGenerator(RepositorySystemSession session, InstallRequest request) {
|
||||
legacyFormat = ConfigUtils.getBoolean(session.getConfigProperties(), false, "maven.metadata.legacy");
|
||||
|
||||
timestamp = (Date) ConfigUtils.getObject(session, new Date(), "maven.startTime");
|
||||
|
||||
snapshots = new LinkedHashMap<>();
|
||||
|
@ -58,7 +54,7 @@ class LocalSnapshotMetadataGenerator implements MetadataGenerator {
|
|||
Object key = LocalSnapshotMetadata.getKey(artifact);
|
||||
LocalSnapshotMetadata snapshotMetadata = snapshots.get(key);
|
||||
if (snapshotMetadata == null) {
|
||||
snapshotMetadata = new LocalSnapshotMetadata(artifact, legacyFormat, timestamp);
|
||||
snapshotMetadata = new LocalSnapshotMetadata(artifact, timestamp);
|
||||
snapshots.put(key, snapshotMetadata);
|
||||
}
|
||||
snapshotMetadata.bind(artifact);
|
||||
|
|
|
@ -34,18 +34,13 @@ abstract class MavenSnapshotMetadata extends MavenMetadata {
|
|||
|
||||
protected final Collection<Artifact> artifacts = new ArrayList<>();
|
||||
|
||||
protected final boolean legacyFormat;
|
||||
|
||||
protected MavenSnapshotMetadata(Metadata metadata, File file, boolean legacyFormat, Date timestamp) {
|
||||
protected MavenSnapshotMetadata(Metadata metadata, File file, Date timestamp) {
|
||||
super(metadata, file, timestamp);
|
||||
this.legacyFormat = legacyFormat;
|
||||
}
|
||||
|
||||
protected static Metadata createRepositoryMetadata(Artifact artifact, boolean legacyFormat) {
|
||||
protected static Metadata createRepositoryMetadata(Artifact artifact) {
|
||||
Metadata metadata = new Metadata();
|
||||
if (!legacyFormat) {
|
||||
metadata.setModelVersion("1.1.0");
|
||||
}
|
||||
metadata.setModelVersion("1.1.0");
|
||||
metadata.setGroupId(artifact.getGroupId());
|
||||
metadata.setArtifactId(artifact.getArtifactId());
|
||||
metadata.setVersion(artifact.getBaseVersion());
|
||||
|
|
|
@ -44,16 +44,16 @@ final class RemoteSnapshotMetadata extends MavenSnapshotMetadata {
|
|||
|
||||
private final Map<String, SnapshotVersion> versions = new LinkedHashMap<>();
|
||||
|
||||
RemoteSnapshotMetadata(Artifact artifact, boolean legacyFormat, Date timestamp) {
|
||||
super(createRepositoryMetadata(artifact, legacyFormat), null, legacyFormat, timestamp);
|
||||
RemoteSnapshotMetadata(Artifact artifact, Date timestamp) {
|
||||
super(createRepositoryMetadata(artifact), null, timestamp);
|
||||
}
|
||||
|
||||
private RemoteSnapshotMetadata(Metadata metadata, File file, boolean legacyFormat, Date timestamp) {
|
||||
super(metadata, file, legacyFormat, timestamp);
|
||||
private RemoteSnapshotMetadata(Metadata metadata, File file, Date timestamp) {
|
||||
super(metadata, file, timestamp);
|
||||
}
|
||||
|
||||
public MavenMetadata setFile(File file) {
|
||||
return new RemoteSnapshotMetadata(metadata, file, legacyFormat, timestamp);
|
||||
return new RemoteSnapshotMetadata(metadata, file, timestamp);
|
||||
}
|
||||
|
||||
public String getExpandedVersion(Artifact artifact) {
|
||||
|
@ -115,9 +115,7 @@ final class RemoteSnapshotMetadata extends MavenSnapshotMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
if (!legacyFormat) {
|
||||
metadata.getVersioning().setSnapshotVersions(new ArrayList<>(versions.values()));
|
||||
}
|
||||
metadata.getVersioning().setSnapshotVersions(new ArrayList<>(versions.values()));
|
||||
}
|
||||
|
||||
private static int getBuildNumber(Metadata metadata) {
|
||||
|
|
|
@ -40,13 +40,9 @@ class RemoteSnapshotMetadataGenerator implements MetadataGenerator {
|
|||
|
||||
private final Map<Object, RemoteSnapshotMetadata> snapshots;
|
||||
|
||||
private final boolean legacyFormat;
|
||||
|
||||
private final Date timestamp;
|
||||
|
||||
RemoteSnapshotMetadataGenerator(RepositorySystemSession session, DeployRequest request) {
|
||||
legacyFormat = ConfigUtils.getBoolean(session, false, "maven.metadata.legacy");
|
||||
|
||||
timestamp = (Date) ConfigUtils.getObject(session, new Date(), "maven.startTime");
|
||||
|
||||
snapshots = new LinkedHashMap<>();
|
||||
|
@ -71,7 +67,7 @@ class RemoteSnapshotMetadataGenerator implements MetadataGenerator {
|
|||
Object key = RemoteSnapshotMetadata.getKey(artifact);
|
||||
RemoteSnapshotMetadata snapshotMetadata = snapshots.get(key);
|
||||
if (snapshotMetadata == null) {
|
||||
snapshotMetadata = new RemoteSnapshotMetadata(artifact, legacyFormat, timestamp);
|
||||
snapshotMetadata = new RemoteSnapshotMetadata(artifact, timestamp);
|
||||
snapshots.put(key, snapshotMetadata);
|
||||
}
|
||||
snapshotMetadata.bind(artifact);
|
||||
|
|
|
@ -62,8 +62,7 @@ class RemoteSnapshotMetadataTest {
|
|||
void gregorianCalendarIsUsed() {
|
||||
String dateBefore = gregorianDate();
|
||||
|
||||
RemoteSnapshotMetadata metadata =
|
||||
new RemoteSnapshotMetadata(new DefaultArtifact("a:b:1-SNAPSHOT"), false, new Date());
|
||||
RemoteSnapshotMetadata metadata = new RemoteSnapshotMetadata(new DefaultArtifact("a:b:1-SNAPSHOT"), new Date());
|
||||
metadata.merge(new Metadata());
|
||||
|
||||
String dateAfter = gregorianDate();
|
||||
|
|
Loading…
Reference in New Issue