mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
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:
parent
9aa2854e00
commit
8358a0e3f3
@ -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()) {
|
||||
|
@ -670,9 +670,9 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
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<T extends Jar & BootArchive> {
|
||||
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);
|
||||
|
@ -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();
|
||||
|
@ -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) -> {
|
||||
|
Loading…
Reference in New Issue
Block a user