Fix reachability-metadata.properties location

Update tools to use the correct `reachability-metadata.properties`
location which should include the version number.

See gh-32738
This commit is contained in:
Phillip Webb
2022-10-17 13:48:00 -07:00
parent 9aa2854e00
commit 8358a0e3f3
4 changed files with 17 additions and 15 deletions

View File

@@ -61,7 +61,7 @@ import org.springframework.util.StringUtils;
*/
public abstract class Packager {
private static final String REACHABILITY_METADATA_PROPERTIES_LOCATION = "META-INF/native-image/%s/%s/reachability-metadata.properties";
private static final String REACHABILITY_METADATA_PROPERTIES_LOCATION = "META-INF/native-image/%s/%s/%s/reachability-metadata.properties";
private static final String MAIN_CLASS_ATTRIBUTE = "Main-Class";
@@ -230,7 +230,7 @@ public abstract class Packager {
for (Map.Entry<String, Library> entry : writtenLibraries.entrySet()) {
LibraryCoordinates coordinates = entry.getValue().getCoordinates();
ZipEntry zipEntry = (coordinates != null) ? sourceJar.getEntry(REACHABILITY_METADATA_PROPERTIES_LOCATION
.formatted(coordinates.getGroupId(), coordinates.getArtifactId())) : null;
.formatted(coordinates.getGroupId(), coordinates.getArtifactId(), coordinates.getVersion())) : null;
if (zipEntry != null) {
try (InputStream inputStream = sourceJar.getInputStream(zipEntry)) {
Properties properties = new Properties();

View File

@@ -622,11 +622,12 @@ abstract class AbstractPackagerTests<P extends Packager> {
File libraryTwo = createLibraryJar();
File libraryThree = createLibraryJar();
File libraryFour = createLibraryJar();
this.testJarFile.addFile("META-INF/native-image/com.example.one/lib-one/reachability-metadata.properties",
this.testJarFile.addFile("META-INF/native-image/com.example.one/lib-one/123/reachability-metadata.properties",
new ByteArrayInputStream("override=true\n".getBytes(StandardCharsets.ISO_8859_1)));
this.testJarFile.addFile("META-INF/native-image/com.example.two/lib-two/reachability-metadata.properties",
this.testJarFile.addFile("META-INF/native-image/com.example.two/lib-two/123/reachability-metadata.properties",
new ByteArrayInputStream("override=true\n".getBytes(StandardCharsets.ISO_8859_1)));
this.testJarFile.addFile("META-INF/native-image/com.example.three/lib-three/reachability-metadata.properties",
this.testJarFile.addFile(
"META-INF/native-image/com.example.three/lib-three/123/reachability-metadata.properties",
new ByteArrayInputStream("other=test\n".getBytes(StandardCharsets.ISO_8859_1)));
P packager = createPackager(this.testJarFile.getFile());
execute(packager, (callback) -> {