Skip to content

Commit

Permalink
Polish Gradle plugin after layering being enabled by default
Browse files Browse the repository at this point in the history
Closes gh-20983
  • Loading branch information
wilkinsona committed Aug 6, 2020
1 parent 9f55818 commit 079b5d3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 24 deletions.
Expand Up @@ -31,7 +31,6 @@
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;

Expand Down Expand Up @@ -168,32 +167,31 @@ public void launchScript(Action<LaunchScriptConfiguration> action) {
}

/**
* 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;
}

/**
* 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
Expand Down Expand Up @@ -290,13 +288,6 @@ private LaunchScriptConfiguration enableLaunchScriptIfNecessary() {
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
Expand Down
Expand Up @@ -261,16 +261,12 @@ private File createPopulatedJar() throws IOException {
}

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();
Expand Down
Expand Up @@ -5,7 +5,6 @@ plugins {

bootJar {
mainClassName = 'com.example.Application'
layered()
}

repositories {
Expand Down
Expand Up @@ -9,7 +9,6 @@ sourceSets {

bootJar {
mainClassName = 'com.example.Application'
layered()
}

repositories {
Expand Down

0 comments on commit 079b5d3

Please sign in to comment.