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:
@@ -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.
|
||||
@@ -56,6 +56,7 @@ import org.springframework.boot.loader.tools.layer.CustomLayers;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Scott Frederick
|
||||
* @author Moritz Halbritter
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public abstract class AbstractPackagerMojo extends AbstractDependencyFilterMojo {
|
||||
@@ -112,13 +113,20 @@ public abstract class AbstractPackagerMojo extends AbstractDependencyFilterMojo
|
||||
@Parameter(defaultValue = "false")
|
||||
public boolean includeSystemScope;
|
||||
|
||||
/**
|
||||
* Include JAR tools.
|
||||
* @since 3.3.0
|
||||
*/
|
||||
@Parameter(defaultValue = "true")
|
||||
public boolean includeTools = true;
|
||||
|
||||
/**
|
||||
* Layer configuration with options to disable layer creation, exclude layer tools
|
||||
* jar, and provide a custom layers configuration file.
|
||||
* @since 2.3.0
|
||||
*/
|
||||
@Parameter
|
||||
private Layers layers;
|
||||
private Layers layers = new Layers();
|
||||
|
||||
/**
|
||||
* Return the type of archive that should be packaged by this MOJO.
|
||||
@@ -164,17 +172,22 @@ public abstract class AbstractPackagerMojo extends AbstractDependencyFilterMojo
|
||||
getLog().info("Layout: " + layout);
|
||||
packager.setLayout(layout.layout());
|
||||
}
|
||||
if (this.layers == null) {
|
||||
packager.setLayers(IMPLICIT_LAYERS);
|
||||
}
|
||||
else if (this.layers.isEnabled()) {
|
||||
if (this.layers.isEnabled()) {
|
||||
packager.setLayers((this.layers.getConfiguration() != null)
|
||||
? getCustomLayers(this.layers.getConfiguration()) : IMPLICIT_LAYERS);
|
||||
packager.setIncludeRelevantJarModeJars(this.layers.isIncludeLayerTools());
|
||||
}
|
||||
packager.setIncludeRelevantJarModeJars(getIncludeRelevantJarModeJars());
|
||||
return packager;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private boolean getIncludeRelevantJarModeJars() {
|
||||
if (!this.includeTools) {
|
||||
return false;
|
||||
}
|
||||
return this.layers.isIncludeLayerTools();
|
||||
}
|
||||
|
||||
private CustomLayers getCustomLayers(File configuration) {
|
||||
try {
|
||||
Document document = getDocumentIfAvailable(configuration);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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.
|
||||
@@ -28,6 +28,7 @@ public class Layers {
|
||||
|
||||
private boolean enabled = true;
|
||||
|
||||
@Deprecated(since = "3.3.0", forRemoval = true)
|
||||
private boolean includeLayerTools = true;
|
||||
|
||||
private File configuration;
|
||||
@@ -43,7 +44,9 @@ public class Layers {
|
||||
/**
|
||||
* Whether to include the layer tools jar.
|
||||
* @return true if layer tools should be included
|
||||
* @deprecated since 3.3.0 for removal in 3.5.0 in favor of {@code includeTools}.
|
||||
*/
|
||||
@Deprecated(since = "3.3.0", forRemoval = true)
|
||||
public boolean isIncludeLayerTools() {
|
||||
return this.includeLayerTools;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user