Fix matching of SNAPSHOT artifacts when customizing layers
Previously the artifact's version was used. In an artifact's version, SNAPSHOT is replaced with the timestamped version number of a specific snapshot. As a result, it no longer matches the *:*:*SNAPSHOT pattern. This commit replaces switches to using the artifact's base version. This preserves the SNAPSHOT in the version number. For non-snapshot artifacts, the version and base version are identical. Fixes gh-23533
This commit is contained in:
parent
cd15cbdc79
commit
bd4934b0fd
|
@ -144,7 +144,7 @@ public class ArtifactsLibraries implements Libraries {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return this.artifact.getVersion();
|
return this.artifact.getBaseVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
package org.springframework.boot.maven;
|
package org.springframework.boot.maven;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
@ -131,4 +132,20 @@ class ArtifactsLibrariesTests {
|
||||||
assertThat(this.libraryCaptor.getAllValues().get(1).getName()).isEqualTo("g2-artifact-1.0.jar");
|
assertThat(this.libraryCaptor.getAllValues().get(1).getName()).isEqualTo("g2-artifact-1.0.jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void libraryCoordinatesVersionUsesBaseVersionOfArtifact() throws IOException {
|
||||||
|
Artifact snapshotArtifact = mock(Artifact.class);
|
||||||
|
given(snapshotArtifact.getType()).willReturn("jar");
|
||||||
|
given(snapshotArtifact.getScope()).willReturn("compile");
|
||||||
|
given(snapshotArtifact.getGroupId()).willReturn("g1");
|
||||||
|
given(snapshotArtifact.getArtifactId()).willReturn("artifact");
|
||||||
|
given(snapshotArtifact.getVersion()).willReturn("1.0-20200929.090327-28");
|
||||||
|
given(snapshotArtifact.getBaseVersion()).willReturn("1.0-SNAPSHOT");
|
||||||
|
given(snapshotArtifact.getFile()).willReturn(new File("a"));
|
||||||
|
given(snapshotArtifact.getArtifactHandler()).willReturn(this.artifactHandler);
|
||||||
|
this.artifacts = Collections.singleton(snapshotArtifact);
|
||||||
|
new ArtifactsLibraries(this.artifacts, null, mock(Log.class)).doWithLibraries(
|
||||||
|
(library) -> assertThat(library.getCoordinates().getVersion()).isEqualTo("1.0-SNAPSHOT"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue