Skip to content

Commit 16f54d2

Browse files
Merge branch '2.7.x'
2 parents 3478e19 + 61fb9f8 commit 16f54d2

File tree

5 files changed

+32
-11
lines changed

5 files changed

+32
-11
lines changed

spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layouts.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* @author Dave Syer
3030
* @author Andy Wilkinson
3131
* @author Madhura Bhave
32+
* @author Scott Frederick
3233
* @since 1.0.0
3334
*/
3435
public final class Layouts {
@@ -160,11 +161,6 @@ public String getClassesLocation() {
160161
return "WEB-INF/classes/";
161162
}
162163

163-
@Override
164-
public String getClasspathIndexFileLocation() {
165-
return "WEB-INF/classpath.idx";
166-
}
167-
168164
@Override
169165
public String getLayersIndexFileLocation() {
170166
return "WEB-INF/layers.idx";

spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -516,15 +516,15 @@ void write(AbstractJarWriter writer) throws IOException {
516516
writtenPaths.add(path);
517517
}
518518
}
519-
if (getLayout() instanceof RepackagingLayout) {
520-
writeClasspathIndex(writtenPaths, (RepackagingLayout) getLayout(), writer);
521-
}
519+
writeClasspathIndexIfNecessary(writtenPaths, getLayout(), writer);
522520
}
523521

524-
private void writeClasspathIndex(List<String> paths, RepackagingLayout layout, AbstractJarWriter writer)
522+
private void writeClasspathIndexIfNecessary(List<String> paths, Layout layout, AbstractJarWriter writer)
525523
throws IOException {
526-
List<String> names = paths.stream().map((path) -> "- \"" + path + "\"").collect(Collectors.toList());
527-
writer.writeIndexFile(layout.getClasspathIndexFileLocation(), names);
524+
if (layout.getClasspathIndexFileLocation() != null) {
525+
List<String> names = paths.stream().map((path) -> "- \"" + path + "\"").collect(Collectors.toList());
526+
writer.writeIndexFile(layout.getClasspathIndexFileLocation(), names);
527+
}
528528
}
529529

530530
/**

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/AbstractArchiveIntegrationTests.java

+5
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ ManifestAssert hasAttribute(String name, String value) {
213213
return this;
214214
}
215215

216+
ManifestAssert doesNotHaveAttribute(String name) {
217+
assertThat(this.actual.getMainAttributes().getValue(name)).isNull();
218+
return this;
219+
}
220+
216221
}
217222

218223
}

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/JarIntegrationTests.java

+10
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,16 @@ void whenJarIsRepackagedWithTheCustomLayers(MavenBuild mavenBuild) {
365365
});
366366
}
367367

368+
@TestTemplate
369+
void repackagedJarContainsClasspathIndex(MavenBuild mavenBuild) {
370+
mavenBuild.project("jar").execute((project) -> {
371+
File repackaged = new File(project, "target/jar-0.0.1.BUILD-SNAPSHOT.jar");
372+
assertThat(jar(repackaged)).manifest(
373+
(manifest) -> manifest.hasAttribute("Spring-Boot-Classpath-Index", "BOOT-INF/classpath.idx"));
374+
assertThat(jar(repackaged)).hasEntryWithName("BOOT-INF/classpath.idx");
375+
});
376+
}
377+
368378
@TestTemplate
369379
void whenJarIsRepackagedWithOutputTimestampConfiguredThenJarIsReproducible(MavenBuild mavenBuild)
370380
throws InterruptedException {

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/WarIntegrationTests.java

+10
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,16 @@ void whenWarIsRepackagedWithTheCustomLayers(MavenBuild mavenBuild) {
210210
});
211211
}
212212

213+
@TestTemplate
214+
void repackagedWarDoesNotContainClasspathIndex(MavenBuild mavenBuild) {
215+
mavenBuild.project("war").execute((project) -> {
216+
File repackaged = new File(project, "target/war-0.0.1.BUILD-SNAPSHOT.war");
217+
assertThat(jar(repackaged))
218+
.manifest((manifest) -> manifest.doesNotHaveAttribute("Spring-Boot-Classpath-Index"));
219+
assertThat(jar(repackaged)).doesNotHaveEntryWithName("BOOT-INF/classpath.idx");
220+
});
221+
}
222+
213223
@TestTemplate
214224
void whenEntryIsExcludedItShouldNotBePresentInTheRepackagedWar(MavenBuild mavenBuild) {
215225
mavenBuild.project("war-exclude-entry").execute((project) -> {

0 commit comments

Comments
 (0)