Add classpath index support for exploded war archives

Update the Maven and Gradle packaging for war files so that a
`classpath.idx` file is written into the archive that provides the
original order of the classpath, as was previously done for jar files.
The `WarLauncher` class will use this file when running as an exploded
archive to ensure that the classpath order is the same as when running
from the far war.

Fixes gh-19875
This commit is contained in:
Scott Frederick
2021-12-09 16:25:30 -06:00
parent 8b5600fca8
commit 8f57f0babb
14 changed files with 168 additions and 76 deletions

View File

@@ -41,6 +41,7 @@ import org.gradle.api.tasks.bundling.War;
*
* @author Andy Wilkinson
* @author Phillip Webb
* @author Scott Frederick
* @since 2.0.0
*/
public class BootWar extends War implements BootArchive {
@@ -55,6 +56,8 @@ public class BootWar extends War implements BootArchive {
private static final String LAYERS_INDEX = "WEB-INF/layers.idx";
private static final String CLASSPATH_INDEX = "WEB-INF/classpath.idx";
private final BootArchiveSupport support;
private final Property<String> mainClass;
@@ -91,8 +94,8 @@ public class BootWar extends War implements BootArchive {
@Override
public void copy() {
this.support.configureManifest(getManifest(), getMainClass().get(), CLASSES_DIRECTORY, LIB_DIRECTORY, null,
(isLayeredDisabled()) ? null : LAYERS_INDEX);
this.support.configureManifest(getManifest(), getMainClass().get(), CLASSES_DIRECTORY, LIB_DIRECTORY,
CLASSPATH_INDEX, (isLayeredDisabled()) ? null : LAYERS_INDEX);
super.copy();
}