Remove classpath index manifest attribute from repackaged war files

Fixes gh-28895
This commit is contained in:
Scott Frederick
2021-12-03 11:41:28 -06:00
parent af60a8a7cf
commit 467c092fdc
5 changed files with 35 additions and 11 deletions

View File

@@ -43,6 +43,7 @@ import static org.assertj.core.api.Assertions.contentOf;
* Base class for archive (jar or war) related Maven plugin integration tests.
*
* @author Andy Wilkinson
* @author Scott Frederick
*/
abstract class AbstractArchiveIntegrationTests {
@@ -201,6 +202,11 @@ abstract class AbstractArchiveIntegrationTests {
return this;
}
ManifestAssert doesNotHaveAttribute(String name) {
assertThat(this.actual.getMainAttributes().getValue(name)).isNull();
return this;
}
}
}

View File

@@ -38,6 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Andy Wilkinson
* @author Madhura Bhave
* @author Scott Frederick
*/
@ExtendWith(MavenBuildExtension.class)
class JarIntegrationTests extends AbstractArchiveIntegrationTests {
@@ -363,6 +364,16 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
});
}
@TestTemplate
void repackagedJarContainsClasspathIndex(MavenBuild mavenBuild) {
mavenBuild.project("jar").execute((project) -> {
File repackaged = new File(project, "target/jar-0.0.1.BUILD-SNAPSHOT.jar");
assertThat(jar(repackaged)).manifest(
(manifest) -> manifest.hasAttribute("Spring-Boot-Classpath-Index", "BOOT-INF/classpath.idx"));
assertThat(jar(repackaged)).hasEntryWithName("BOOT-INF/classpath.idx");
});
}
@TestTemplate
void whenJarIsRepackagedWithOutputTimestampConfiguredThenJarIsReproducible(MavenBuild mavenBuild)
throws InterruptedException {

View File

@@ -38,6 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* Integration tests for the Maven plugin's war support.
*
* @author Andy Wilkinson
* @author Scott Frederick
*/
@ExtendWith(MavenBuildExtension.class)
class WarIntegrationTests extends AbstractArchiveIntegrationTests {
@@ -190,6 +191,16 @@ class WarIntegrationTests extends AbstractArchiveIntegrationTests {
});
}
@TestTemplate
void repackagedWarDoesNotContainClasspathIndex(MavenBuild mavenBuild) {
mavenBuild.project("war").execute((project) -> {
File repackaged = new File(project, "target/war-0.0.1.BUILD-SNAPSHOT.war");
assertThat(jar(repackaged))
.manifest((manifest) -> manifest.doesNotHaveAttribute("Spring-Boot-Classpath-Index"));
assertThat(jar(repackaged)).doesNotHaveEntryWithName("BOOT-INF/classpath.idx");
});
}
@TestTemplate
void whenEntryIsExcludedItShouldNotBePresentInTheRepackagedWar(MavenBuild mavenBuild) {
mavenBuild.project("war-exclude-entry").execute((project) -> {