Switch layering on by default

Closes gh-20983
This commit is contained in:
Madhura Bhave
2020-07-27 18:45:00 -07:00
parent eaca13cb01
commit 41f5ba9077
24 changed files with 268 additions and 61 deletions

View File

@@ -64,7 +64,7 @@ public class BootJar extends Jar implements BootArchive {
private FileCollection classpath;
private LayeredSpec layered;
private LayeredSpec layered = new LayeredSpec();
/**
* Creates a new {@code BootJar} task.
@@ -98,13 +98,17 @@ public class BootJar extends Jar implements BootArchive {
@Override
public void copy() {
this.support.configureManifest(getManifest(), getMainClassName(), CLASSES_DIRECTORY, LIB_DIRECTORY,
CLASSPATH_INDEX, (this.layered != null) ? LAYERS_INDEX : null);
CLASSPATH_INDEX, (isLayeredDisabled()) ? null : LAYERS_INDEX);
super.copy();
}
private boolean isLayeredDisabled() {
return this.layered != null && !this.layered.isEnabled();
}
@Override
protected CopyAction createCopyAction() {
if (this.layered != null) {
if (!isLayeredDisabled()) {
JavaPluginConvention javaPluginConvention = getProject().getConvention()
.findPlugin(JavaPluginConvention.class);
Iterable<SourceSet> sourceSets = (javaPluginConvention != null) ? javaPluginConvention.getSourceSets()

View File

@@ -52,6 +52,8 @@ public class LayeredSpec {
private boolean includeLayerTools = true;
private boolean enabled = true;
private ApplicationSpec application = new ApplicationSpec();
private DependenciesSpec dependencies = new DependenciesSpec();
@@ -80,6 +82,24 @@ public class LayeredSpec {
this.includeLayerTools = includeLayerTools;
}
/**
* Returns whether the layers.idx should be included in the jar.
* @return whether the layers.idx should be included
*/
@Input
public boolean isEnabled() {
return this.enabled;
}
/**
* Sets whether the layers.idx should be included in the jar.
* @param enabled {@code true} layers.idx should be included in the jar, otherwise
* {@code false}
*/
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
/**
* Returns the {@link ApplicationSpec} that controls the layers to which application
* classes and resources belong.