Polish Gradle plugin after layering being enabled by default
Closes gh-20983
This commit is contained in:
parent
9f558181d5
commit
079b5d3f50
|
|
@ -31,7 +31,6 @@ import org.gradle.api.plugins.JavaPluginConvention;
|
||||||
import org.gradle.api.specs.Spec;
|
import org.gradle.api.specs.Spec;
|
||||||
import org.gradle.api.tasks.Internal;
|
import org.gradle.api.tasks.Internal;
|
||||||
import org.gradle.api.tasks.Nested;
|
import org.gradle.api.tasks.Nested;
|
||||||
import org.gradle.api.tasks.Optional;
|
|
||||||
import org.gradle.api.tasks.SourceSet;
|
import org.gradle.api.tasks.SourceSet;
|
||||||
import org.gradle.api.tasks.bundling.Jar;
|
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.
|
* Returns the spec that describes the layers in a layered jar.
|
||||||
* @return the spec for the layers or {@code null}.
|
* @return the spec for the layers
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
*/
|
*/
|
||||||
@Nested
|
@Nested
|
||||||
@Optional
|
|
||||||
public LayeredSpec getLayered() {
|
public LayeredSpec getLayered() {
|
||||||
return this.layered;
|
return this.layered;
|
||||||
}
|
}
|
||||||
|
|
@ -181,19 +179,19 @@ public class BootJar extends Jar implements BootArchive {
|
||||||
/**
|
/**
|
||||||
* Configures the jar to be layered using the default layering.
|
* Configures the jar to be layered using the default layering.
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
|
* @deprecated since 2.4.0 as layering as now enabled by default.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void layered() {
|
public void layered() {
|
||||||
enableLayeringIfNecessary();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the jar to be layered, customizing the layers using the given
|
* Configures the jar's layering using the given {@code action}.
|
||||||
* {@code action}.
|
|
||||||
* @param action the action to apply
|
* @param action the action to apply
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
*/
|
*/
|
||||||
public void layered(Action<LayeredSpec> action) {
|
public void layered(Action<LayeredSpec> action) {
|
||||||
action.execute(enableLayeringIfNecessary());
|
action.execute(this.layered);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -290,13 +288,6 @@ public class BootJar extends Jar implements BootArchive {
|
||||||
return launchScript;
|
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.
|
* Syntactic sugar that makes {@link CopySpec#into} calls a little easier to read.
|
||||||
* @param <T> the result type
|
* @param <T> the result type
|
||||||
|
|
|
||||||
|
|
@ -261,16 +261,12 @@ class BootJarTests extends AbstractBootArchiveTests<TestBootJar> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private File createLayeredJar() throws IOException {
|
private File createLayeredJar() throws IOException {
|
||||||
return createLayeredJar(null);
|
return createLayeredJar((spec) -> {
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private File createLayeredJar(Action<LayeredSpec> action) throws IOException {
|
private File createLayeredJar(Action<LayeredSpec> action) throws IOException {
|
||||||
if (action != null) {
|
getTask().layered(action);
|
||||||
getTask().layered(action);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
getTask().layered();
|
|
||||||
}
|
|
||||||
addContent();
|
addContent();
|
||||||
executeTask();
|
executeTask();
|
||||||
return getTask().getArchiveFile().get().getAsFile();
|
return getTask().getArchiveFile().get().getAsFile();
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ plugins {
|
||||||
|
|
||||||
bootJar {
|
bootJar {
|
||||||
mainClassName = 'com.example.Application'
|
mainClassName = 'com.example.Application'
|
||||||
layered()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ sourceSets {
|
||||||
|
|
||||||
bootJar {
|
bootJar {
|
||||||
mainClassName = 'com.example.Application'
|
mainClassName = 'com.example.Application'
|
||||||
layered()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue