Implement extract and list-layers command

Adds a new jarmode called 'tools'. This provides two commands,
'extract' and 'list-layers'. list-layers is the same as list from
the layertools.

extract is able to extract the JAR in four different modes:

- CDS compatible extraction with libraries in a lib folder and a runner
.jar
- CDS compatible as above, but with layers
- Launcher based
- Launcher based with layers. This is essentially the same as extract
  from the layertools

The commands in layertools have been deprecated in favor of the commands
in 'tools'.

This also changes the behavior of layers.enabled from the Gradle and
Maven plugin: before this commit, layers.enabled prevents the inclusion
of the layer index file as well as the layertools JAR.
After this commit, layers.enabled only prevents the inclusion of the
layer index file.

layer.includeLayerTools have been deprecated in favor of includeTools,
and the layertools JAR has been renamed to tools.

Closes gh-38276
This commit is contained in:
Moritz Halbritter
2024-02-09 15:04:46 +01:00
parent 2c4fb5baaa
commit 793aca60d2
121 changed files with 2780 additions and 612 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,6 +39,7 @@ import org.springframework.boot.loader.tools.LoaderImplementation;
* A Spring Boot "fat" archive task.
*
* @author Andy Wilkinson
* @author Moritz Halbritter
* @since 2.0.0
*/
public interface BootArchive extends Task {
@@ -144,4 +145,13 @@ public interface BootArchive extends Task {
@Optional
Property<LoaderImplementation> getLoaderImplementation();
/**
* Returns whether the JAR tools should be included as a dependency in the layered
* archive.
* @return whether the JAR tools should be included
* @since 3.3.0
*/
@Input
Property<Boolean> getIncludeTools();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -129,7 +129,7 @@ class BootArchiveSupport {
CopyAction createCopyAction(Jar jar, ResolvedDependencies resolvedDependencies,
LoaderImplementation loaderImplementation, boolean supportsSignatureFile, LayerResolver layerResolver,
String layerToolsLocation) {
String jarmodeToolsLocation) {
File output = jar.getArchiveFile().get().getAsFile();
Manifest manifest = jar.getManifest();
boolean preserveFileTimestamps = jar.isPreserveFileTimestamps();
@@ -143,7 +143,7 @@ class BootArchiveSupport {
Function<FileCopyDetails, ZipCompression> compressionResolver = this.compressionResolver;
String encoding = jar.getMetadataCharset();
CopyAction action = new BootZipCopyAction(output, manifest, preserveFileTimestamps, dirMode, fileMode,
includeDefaultLoader, layerToolsLocation, requiresUnpack, exclusions, launchScript, librarySpec,
includeDefaultLoader, jarmodeToolsLocation, requiresUnpack, exclusions, launchScript, librarySpec,
compressionResolver, encoding, resolvedDependencies, supportsSignatureFile, layerResolver,
loaderImplementation);
return jar.isReproducibleFileOrder() ? new ReproducibleOrderingCopyAction(action) : action;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -88,6 +88,7 @@ public abstract class BootJar extends Jar implements BootArchive {
this.projectName = project.provider(project::getName);
this.projectVersion = project.provider(project::getVersion);
this.resolvedDependencies = new ResolvedDependencies(project);
getIncludeTools().convention(true);
}
private void configureBootInfSpec(CopySpec bootInfSpec) {
@@ -144,13 +145,21 @@ public abstract class BootJar extends Jar implements BootArchive {
@Override
protected CopyAction createCopyAction() {
LoaderImplementation loaderImplementation = getLoaderImplementation().getOrElse(LoaderImplementation.DEFAULT);
LayerResolver layerResolver = null;
if (!isLayeredDisabled()) {
LayerResolver layerResolver = new LayerResolver(this.resolvedDependencies, this.layered, this::isLibrary);
String layerToolsLocation = this.layered.getIncludeLayerTools().get() ? LIB_DIRECTORY : null;
return this.support.createCopyAction(this, this.resolvedDependencies, loaderImplementation, true,
layerResolver, layerToolsLocation);
layerResolver = new LayerResolver(this.resolvedDependencies, this.layered, this::isLibrary);
}
return this.support.createCopyAction(this, this.resolvedDependencies, loaderImplementation, true);
String jarmodeToolsLocation = isIncludeJarmodeTools() ? LIB_DIRECTORY : null;
return this.support.createCopyAction(this, this.resolvedDependencies, loaderImplementation, true, layerResolver,
jarmodeToolsLocation);
}
@SuppressWarnings("removal")
private boolean isIncludeJarmodeTools() {
if (!this.getIncludeTools().get()) {
return false;
}
return this.layered.getIncludeLayerTools().get();
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -87,6 +87,7 @@ public abstract class BootWar extends War implements BootArchive {
this.projectName = project.provider(project::getName);
this.projectVersion = project.provider(project::getVersion);
this.resolvedDependencies = new ResolvedDependencies(project);
getIncludeTools().convention(true);
}
private Object getProvidedLibFiles() {
@@ -118,13 +119,21 @@ public abstract class BootWar extends War implements BootArchive {
@Override
protected CopyAction createCopyAction() {
LoaderImplementation loaderImplementation = getLoaderImplementation().getOrElse(LoaderImplementation.DEFAULT);
LayerResolver layerResolver = null;
if (!isLayeredDisabled()) {
LayerResolver layerResolver = new LayerResolver(this.resolvedDependencies, this.layered, this::isLibrary);
String layerToolsLocation = this.layered.getIncludeLayerTools().get() ? LIB_DIRECTORY : null;
return this.support.createCopyAction(this, this.resolvedDependencies, loaderImplementation, false,
layerResolver, layerToolsLocation);
layerResolver = new LayerResolver(this.resolvedDependencies, this.layered, this::isLibrary);
}
return this.support.createCopyAction(this, this.resolvedDependencies, loaderImplementation, false);
String jarmodeToolsLocation = isIncludeJarmodeTools() ? LIB_DIRECTORY : null;
return this.support.createCopyAction(this, this.resolvedDependencies, loaderImplementation, false,
layerResolver, jarmodeToolsLocation);
}
@SuppressWarnings("removal")
private boolean isIncludeJarmodeTools() {
if (!this.getIncludeTools().get()) {
return false;
}
return this.layered.getIncludeLayerTools().get();
}
@Override

View File

@@ -96,7 +96,7 @@ class BootZipCopyAction implements CopyAction {
private final boolean includeDefaultLoader;
private final String layerToolsLocation;
private final String jarmodeToolsLocation;
private final Spec<FileTreeElement> requiresUnpack;
@@ -119,7 +119,7 @@ class BootZipCopyAction implements CopyAction {
private final LoaderImplementation loaderImplementation;
BootZipCopyAction(File output, Manifest manifest, boolean preserveFileTimestamps, Integer dirMode, Integer fileMode,
boolean includeDefaultLoader, String layerToolsLocation, Spec<FileTreeElement> requiresUnpack,
boolean includeDefaultLoader, String jarmodeToolsLocation, Spec<FileTreeElement> requiresUnpack,
Spec<FileTreeElement> exclusions, LaunchScriptConfiguration launchScript, Spec<FileCopyDetails> librarySpec,
Function<FileCopyDetails, ZipCompression> compressionResolver, String encoding,
ResolvedDependencies resolvedDependencies, boolean supportsSignatureFile, LayerResolver layerResolver,
@@ -130,7 +130,7 @@ class BootZipCopyAction implements CopyAction {
this.dirMode = dirMode;
this.fileMode = fileMode;
this.includeDefaultLoader = includeDefaultLoader;
this.layerToolsLocation = layerToolsLocation;
this.jarmodeToolsLocation = jarmodeToolsLocation;
this.requiresUnpack = requiresUnpack;
this.exclusions = exclusions;
this.launchScript = launchScript;
@@ -342,8 +342,8 @@ class BootZipCopyAction implements CopyAction {
}
private void writeJarToolsIfNecessary() throws IOException {
if (BootZipCopyAction.this.layerToolsLocation != null) {
writeJarModeLibrary(BootZipCopyAction.this.layerToolsLocation, JarModeLibrary.LAYER_TOOLS);
if (BootZipCopyAction.this.jarmodeToolsLocation != null) {
writeJarModeLibrary(BootZipCopyAction.this.jarmodeToolsLocation, JarModeLibrary.TOOLS);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -72,8 +72,10 @@ public abstract class LayeredSpec {
* archive.
* @return whether the layer tools should be included
* @since 3.0.0
* @deprecated since 3.3.0 for removal in 3.5.0 in favor of {@code includeTools}.
*/
@Input
@Deprecated(since = "3.3.0", forRemoval = true)
public abstract Property<Boolean> getIncludeLayerTools();
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,6 +66,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Andy Wilkinson
* @author Madhura Bhave
* @author Scott Frederick
* @author Moritz Halbritter
*/
abstract class AbstractBootArchiveIntegrationTests {
@@ -332,6 +333,18 @@ abstract class AbstractBootArchiveIntegrationTests {
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
}
@TestTemplate
void notUpToDateWhenBuiltWithToolsAndThenWithoutTools() {
assertThat(this.gradleBuild.scriptProperty("includeTools", "")
.build(this.taskName)
.task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("includeTools", "includeTools = false")
.build(this.taskName)
.task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
}
@TestTemplate
void layersWithCustomSourceSet() {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
@@ -345,7 +358,7 @@ abstract class AbstractBootArchiveIntegrationTests {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
Map<String, List<String>> indexedLayers;
String layerToolsJar = this.libPath + JarModeLibrary.LAYER_TOOLS.getName();
String layerToolsJar = this.libPath + JarModeLibrary.TOOLS.getName();
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
assertThat(jarFile.getEntry(layerToolsJar)).isNotNull();
assertThat(jarFile.getEntry(this.libPath + "commons-lang3-3.9.jar")).isNotNull();
@@ -397,7 +410,7 @@ abstract class AbstractBootArchiveIntegrationTests {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
Map<String, List<String>> indexedLayers;
String layerToolsJar = this.libPath + JarModeLibrary.LAYER_TOOLS.getName();
String layerToolsJar = this.libPath + JarModeLibrary.TOOLS.getName();
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
assertThat(jarFile.getEntry(layerToolsJar)).isNotNull();
assertThat(jarFile.getEntry(this.libPath + "alpha-1.2.3.jar")).isNotNull();
@@ -443,7 +456,7 @@ abstract class AbstractBootArchiveIntegrationTests {
BuildResult build = this.gradleBuild.build(this.taskName);
assertThat(build.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
Map<String, List<String>> indexedLayers;
String layerToolsJar = this.libPath + JarModeLibrary.LAYER_TOOLS.getName();
String layerToolsJar = this.libPath + JarModeLibrary.TOOLS.getName();
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
assertThat(jarFile.getEntry(layerToolsJar)).isNotNull();
assertThat(jarFile.getEntry(this.libPath + "commons-lang3-3.9.jar")).isNotNull();
@@ -490,7 +503,7 @@ abstract class AbstractBootArchiveIntegrationTests {
BuildResult build = this.gradleBuild.build(this.taskName);
assertThat(build.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
Map<String, List<String>> indexedLayers;
String layerToolsJar = this.libPath + JarModeLibrary.LAYER_TOOLS.getName();
String layerToolsJar = this.libPath + JarModeLibrary.TOOLS.getName();
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
assertThat(jarFile.getEntry(layerToolsJar)).isNotNull();
assertThat(jarFile.getEntry(this.libPath + "alpha-1.2.3.jar")).isNotNull();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -80,6 +80,7 @@ import static org.mockito.Mockito.mock;
* @param <T> the type of the concrete BootArchive implementation
* @author Andy Wilkinson
* @author Scott Frederick
* @author Moritz Halbritter
*/
abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
@@ -496,7 +497,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Lib")).isEqualTo(this.libPath);
assertThat(jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Layers-Index"))
.isEqualTo(this.indexPath + "layers.idx");
assertThat(getEntryNames(jarFile)).contains(this.libPath + JarModeLibrary.LAYER_TOOLS.getName());
assertThat(getEntryNames(jarFile)).contains(this.libPath + JarModeLibrary.TOOLS.getName());
}
}
@@ -530,7 +531,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
List<String> index = entryLines(jarFile, this.indexPath + "layers.idx");
assertThat(getLayerNames(index)).containsExactly("dependencies", "spring-boot-loader",
"snapshot-dependencies", "application");
String layerToolsJar = this.libPath + JarModeLibrary.LAYER_TOOLS.getName();
String layerToolsJar = this.libPath + JarModeLibrary.TOOLS.getName();
List<String> expected = new ArrayList<>();
expected.add("- \"dependencies\":");
expected.add(" - \"" + this.libPath + "first-library.jar\"");
@@ -584,7 +585,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
List<String> index = entryLines(jarFile, this.indexPath + "layers.idx");
assertThat(getLayerNames(index)).containsExactly("my-deps", "my-internal-deps", "my-snapshot-deps",
"resources", "application");
String layerToolsJar = this.libPath + JarModeLibrary.LAYER_TOOLS.getName();
String layerToolsJar = this.libPath + JarModeLibrary.TOOLS.getName();
List<String> expected = new ArrayList<>();
expected.add("- \"my-deps\":");
expected.add(" - \"" + layerToolsJar + "\"");
@@ -614,15 +615,32 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
@Test
void whenArchiveIsLayeredThenLayerToolsAreAddedToTheJar() throws IOException {
List<String> entryNames = getEntryNames(createLayeredJar());
assertThat(entryNames).contains(this.libPath + JarModeLibrary.LAYER_TOOLS.getName());
assertThat(entryNames).contains(this.libPath + JarModeLibrary.TOOLS.getName());
}
@Test
void shouldAddToolsToTheJar() throws IOException {
this.task.getMainClass().set("com.example.Main");
executeTask();
List<String> entryNames = getEntryNames(this.task.getArchiveFile().get().getAsFile());
assertThat(entryNames).isNotEmpty().contains(this.libPath + JarModeLibrary.TOOLS.getName());
}
@Test
@SuppressWarnings("removal")
void whenArchiveIsLayeredAndIncludeLayerToolsIsFalseThenLayerToolsAreNotAddedToTheJar() throws IOException {
List<String> entryNames = getEntryNames(
createLayeredJar((configuration) -> configuration.getIncludeLayerTools().set(false)));
assertThat(entryNames).isNotEmpty()
.doesNotContain(this.indexPath + "layers/dependencies/lib/spring-boot-jarmode-layertools.jar");
assertThat(entryNames).isNotEmpty().doesNotContain(this.libPath + JarModeLibrary.TOOLS.getName());
}
@Test
void whenIncludeToolsIsFalseThenToolsAreNotAddedToTheJar() throws IOException {
this.task.getIncludeTools().set(false);
this.task.getMainClass().set("com.example.Main");
executeTask();
List<String> entryNames = getEntryNames(this.task.getArchiveFile().get().getAsFile());
assertThat(entryNames).isNotEmpty().doesNotContain(this.libPath + JarModeLibrary.TOOLS.getName());
}
protected File jarFile(String name) throws IOException {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -67,7 +67,7 @@ class BootJarIntegrationTests extends AbstractBootArchiveIntegrationTests {
assertThat(output).containsPattern("1\\. .*classes");
assertThat(output).containsPattern("2\\. .*library-1.0-SNAPSHOT.jar");
assertThat(output).containsPattern("3\\. .*commons-lang3-3.9.jar");
assertThat(output).containsPattern("4\\. .*spring-boot-jarmode-layertools.*.jar");
assertThat(output).containsPattern("4\\. .*spring-boot-jarmode-tools.*.jar");
assertThat(output).doesNotContain("5. ");
}
@@ -77,7 +77,7 @@ class BootJarIntegrationTests extends AbstractBootArchiveIntegrationTests {
BuildResult result = this.gradleBuild.build("launch");
String output = result.getOutput();
assertThat(output).containsPattern("1\\. .*classes");
assertThat(output).containsPattern("2\\. .*spring-boot-jarmode-layertools.*.jar");
assertThat(output).containsPattern("2\\. .*spring-boot-jarmode-tools.*.jar");
assertThat(output).containsPattern("3\\. .*library-1.0-SNAPSHOT.jar");
assertThat(output).containsPattern("4\\. .*commons-lang3-3.9.jar");
assertThat(output).doesNotContain("5. ");

View File

@@ -38,12 +38,12 @@ dependencies {
task listLayers(type: JavaExec) {
classpath = bootJar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "list"
systemProperties = [ "jarmode": "tools" ]
args "list-layers"
}
task extractLayers(type: JavaExec) {
classpath = bootJar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "extract"
systemProperties = [ "jarmode": "tools" ]
args "extract", "--layers", "--launcher"
}

View File

@@ -21,12 +21,12 @@ dependencies {
task listLayers(type: JavaExec) {
classpath = bootJar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "list"
systemProperties = [ "jarmode": "tools" ]
args "list-layers"
}
task extractLayers(type: JavaExec) {
classpath = bootJar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "extract"
systemProperties = [ "jarmode": "tools" ]
args "extract", "--layers", "--launcher"
}

View File

@@ -24,12 +24,12 @@ dependencies {
task listLayers(type: JavaExec) {
classpath = bootJar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "list"
systemProperties = [ "jarmode": "tools" ]
args "list-layers"
}
task extractLayers(type: JavaExec) {
classpath = bootJar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "extract"
systemProperties = [ "jarmode": "tools" ]
args "extract", "--layers", "--launcher"
}

View File

@@ -55,12 +55,12 @@ dependencies {
task listLayers(type: JavaExec) {
classpath = bootJar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "list"
systemProperties = [ "jarmode": "tools" ]
args "list-layers"
}
task extractLayers(type: JavaExec) {
classpath = bootJar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "extract"
systemProperties = [ "jarmode": "tools" ]
args "extract", "--layers", "--launcher"
}

View File

@@ -33,12 +33,12 @@ dependencies {
task listLayers(type: JavaExec) {
classpath = bootJar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "list"
systemProperties = [ "jarmode": "tools" ]
args "list-layers"
}
task extractLayers(type: JavaExec) {
classpath = bootJar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "extract"
systemProperties = [ "jarmode": "tools" ]
args "extract", "--layers", "--launcher"
}

View File

@@ -0,0 +1,9 @@
plugins {
id 'java'
id 'org.springframework.boot' version '{version}'
}
bootJar {
mainClass = 'com.example.Application'
{includeTools}
}

View File

@@ -39,12 +39,12 @@ dependencies {
task listLayers(type: JavaExec) {
classpath = bootWar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "list"
systemProperties = [ "jarmode": "tools" ]
args "list-layers"
}
task extractLayers(type: JavaExec) {
classpath = bootWar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "extract"
systemProperties = [ "jarmode": "tools" ]
args "extract", "--layers", "--launcher"
}

View File

@@ -22,12 +22,12 @@ dependencies {
task listLayers(type: JavaExec) {
classpath = bootWar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "list"
systemProperties = [ "jarmode": "tools" ]
args "list-layers"
}
task extractLayers(type: JavaExec) {
classpath = bootWar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "extract"
systemProperties = [ "jarmode": "tools" ]
args "extract", "--layers", "--launcher"
}

View File

@@ -25,12 +25,12 @@ dependencies {
task listLayers(type: JavaExec) {
classpath = bootWar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "list"
systemProperties = [ "jarmode": "tools" ]
args "list-layers"
}
task extractLayers(type: JavaExec) {
classpath = bootWar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "extract"
systemProperties = [ "jarmode": "tools" ]
args "extract", "--layers", "--launcher"
}

View File

@@ -56,12 +56,12 @@ dependencies {
task listLayers(type: JavaExec) {
classpath = bootWar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "list"
systemProperties = [ "jarmode": "tools" ]
args "list-layers"
}
task extractLayers(type: JavaExec) {
classpath = bootWar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "extract"
systemProperties = [ "jarmode": "tools" ]
args "extract", "--layers", "--launcher"
}

View File

@@ -34,12 +34,12 @@ dependencies {
task listLayers(type: JavaExec) {
classpath = bootWar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "list"
systemProperties = [ "jarmode": "tools" ]
args "list-layers"
}
task extractLayers(type: JavaExec) {
classpath = bootWar.outputs.files
systemProperties = [ "jarmode": "layertools" ]
args "extract"
systemProperties = [ "jarmode": "tools" ]
args "extract", "--layers", "--launcher"
}

View File

@@ -0,0 +1,10 @@
plugins {
id 'java'
id 'org.springframework.boot' version '{version}'
id 'war'
}
bootWar {
mainClass = 'com.example.Application'
{includeTools}
}