Polish Gradle plugin after layering being enabled by default

Closes gh-20983
This commit is contained in:
Andy Wilkinson 2020-08-06 11:37:09 +01:00
parent 9f558181d5
commit 079b5d3f50
4 changed files with 9 additions and 24 deletions

View File

@ -31,7 +31,6 @@ import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.specs.Spec;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Nested;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.bundling.Jar;
@ -168,12 +167,11 @@ public class BootJar extends Jar implements BootArchive {
}
/**
* Returns the spec that describes the layers in a layerd jar.
* @return the spec for the layers or {@code null}.
* Returns the spec that describes the layers in a layered jar.
* @return the spec for the layers
* @since 2.3.0
*/
@Nested
@Optional
public LayeredSpec getLayered() {
return this.layered;
}
@ -181,19 +179,19 @@ public class BootJar extends Jar implements BootArchive {
/**
* Configures the jar to be layered using the default layering.
* @since 2.3.0
* @deprecated since 2.4.0 as layering as now enabled by default.
*/
@Deprecated
public void layered() {
enableLayeringIfNecessary();
}
/**
* Configures the jar to be layered, customizing the layers using the given
* {@code action}.
* Configures the jar's layering using the given {@code action}.
* @param action the action to apply
* @since 2.3.0
*/
public void layered(Action<LayeredSpec> action) {
action.execute(enableLayeringIfNecessary());
action.execute(this.layered);
}
@Override
@ -290,13 +288,6 @@ public class BootJar extends Jar implements BootArchive {
return launchScript;
}
private LayeredSpec enableLayeringIfNecessary() {
if (this.layered == null) {
this.layered = new LayeredSpec();
}
return this.layered;
}
/**
* Syntactic sugar that makes {@link CopySpec#into} calls a little easier to read.
* @param <T> the result type

View File

@ -261,16 +261,12 @@ class BootJarTests extends AbstractBootArchiveTests<TestBootJar> {
}
private File createLayeredJar() throws IOException {
return createLayeredJar(null);
return createLayeredJar((spec) -> {
});
}
private File createLayeredJar(Action<LayeredSpec> action) throws IOException {
if (action != null) {
getTask().layered(action);
}
else {
getTask().layered();
}
getTask().layered(action);
addContent();
executeTask();
return getTask().getArchiveFile().get().getAsFile();

View File

@ -5,7 +5,6 @@ plugins {
bootJar {
mainClassName = 'com.example.Application'
layered()
}
repositories {