diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java index b50e6c68f16..04f34e2c652 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java @@ -76,10 +76,10 @@ class BootZipCopyAction implements CopyAction { static final long CONSTANT_TIME_FOR_ZIP_ENTRIES = new GregorianCalendar(1980, Calendar.FEBRUARY, 1, 0, 0, 0) .getTimeInMillis(); - 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 Pattern REACHABILITY_METADATA_PROPERTIES_LOCATION_PATTERN = Pattern - .compile(REACHABILITY_METADATA_PROPERTIES_LOCATION.formatted(".*", ".*")); + .compile(REACHABILITY_METADATA_PROPERTIES_LOCATION.formatted(".*", ".*", ".*")); private final File output; @@ -356,8 +356,8 @@ class BootZipCopyAction implements CopyAction { .find(entry.getValue().getFile()); LibraryCoordinates coordinates = (descriptor != null) ? descriptor.getCoordinates() : null; FileCopyDetails propertiesFile = (coordinates != null) - ? this.reachabilityMetadataProperties.get(REACHABILITY_METADATA_PROPERTIES_LOCATION - .formatted(coordinates.getGroupId(), coordinates.getArtifactId())) + ? this.reachabilityMetadataProperties.get(REACHABILITY_METADATA_PROPERTIES_LOCATION.formatted( + coordinates.getGroupId(), coordinates.getArtifactId(), coordinates.getVersion())) : null; if (propertiesFile != null) { try (InputStream inputStream = propertiesFile.open()) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java index ea70eefe335..0a74ea64c1a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java @@ -670,9 +670,9 @@ abstract class AbstractBootArchiveTests { File css = new File(staticResources, "test.css"); css.createNewFile(); if (addReachabilityProperties) { - createReachabilityProperties(resourcesMain, "com.example", "first-library", "true"); - createReachabilityProperties(resourcesMain, "com.example", "second-library", "true"); - createReachabilityProperties(resourcesMain, "com.example", "fourth-library", "false"); + createReachabilityProperties(resourcesMain, "com.example", "first-library", "1.0.0", "true"); + createReachabilityProperties(resourcesMain, "com.example", "second-library", "1.0.0", "true"); + createReachabilityProperties(resourcesMain, "com.example", "fourth-library", "1.0.0", "false"); } this.task.classpath(classesJavaMain, resourcesMain, jarFile("first-library.jar"), jarFile("second-library.jar"), jarFile("third-library-SNAPSHOT.jar"), jarFile("fourth-library.jar"), @@ -707,9 +707,10 @@ abstract class AbstractBootArchiveTests { populateResolvedDependencies(configuration); } - protected void createReachabilityProperties(File directory, String groupId, String artifactId, String override) - throws IOException { - File targetDirectory = new File(directory, "META-INF/native-image/%s/%s".formatted(groupId, artifactId)); + protected void createReachabilityProperties(File directory, String groupId, String artifactId, String version, + String override) throws IOException { + File targetDirectory = new File(directory, + "META-INF/native-image/%s/%s/%s".formatted(groupId, artifactId, version)); File target = new File(targetDirectory, "reachability-metadata.properties"); targetDirectory.mkdirs(); FileCopyUtils.copy("override=%s\n".formatted(override).getBytes(StandardCharsets.ISO_8859_1), target); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.java index 981420476b8..845e4d49787 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.java @@ -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 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(); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/AbstractPackagerTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/AbstractPackagerTests.java index 62222280db2..6d7b80a329e 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/AbstractPackagerTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/AbstractPackagerTests.java @@ -622,11 +622,12 @@ abstract class AbstractPackagerTests

{ 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) -> {