Update BootWar to support Gradle's configuration cache
See gh-22922
This commit is contained in:
parent
081ef2d905
commit
83cfd3b2e6
|
@ -18,6 +18,7 @@ package org.springframework.boot.gradle.tasks.bundling;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.Project;
|
||||
|
@ -59,7 +60,7 @@ public class BootWar extends War implements BootArchive {
|
|||
* Creates a new {@code BootWar} task.
|
||||
*/
|
||||
public BootWar() {
|
||||
this.support = new BootArchiveSupport(LAUNCHER, this::isLibrary, this::resolveZipCompression);
|
||||
this.support = new BootArchiveSupport(LAUNCHER, new LibrarySpec(), new ZipCompressionResolver());
|
||||
this.mainClass = getProject().getObjects().property(String.class);
|
||||
getWebInf().into("lib-provided", fromCallTo(this::getProvidedLibFiles));
|
||||
this.support.moveModuleInfoToRoot(getRootSpec());
|
||||
|
@ -232,4 +233,22 @@ public class BootWar extends War implements BootArchive {
|
|||
return callable;
|
||||
}
|
||||
|
||||
private final class LibrarySpec implements Spec<FileCopyDetails> {
|
||||
|
||||
@Override
|
||||
public boolean isSatisfiedBy(FileCopyDetails details) {
|
||||
return isLibrary(details);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final class ZipCompressionResolver implements Function<FileCopyDetails, ZipCompression> {
|
||||
|
||||
@Override
|
||||
public ZipCompression apply(FileCopyDetails details) {
|
||||
return resolveZipCompression(details);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.springframework.boot.gradle.junit.GradleCompatibility;
|
|||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@GradleCompatibility
|
||||
@GradleCompatibility(configurationCache = true)
|
||||
class BootWarIntegrationTests extends AbstractBootArchiveIntegrationTests {
|
||||
|
||||
BootWarIntegrationTests() {
|
||||
|
|
|
@ -4,4 +4,4 @@ plugins {
|
|||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
mainClassName = 'com.example.CustomMain'
|
||||
mainClass = 'com.example.CustomMain'
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
plugins {
|
||||
id 'war'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
plugins {
|
||||
id 'war'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.CustomMain'
|
||||
duplicatesStrategy = "exclude"
|
||||
}
|
||||
|
||||
configurations {
|
||||
provided
|
||||
}
|
||||
|
||||
sourceSets.all {
|
||||
compileClasspath += configurations.provided
|
||||
runtimeClasspath += configurations.provided
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.apache.commons:commons-lang3:3.6")
|
||||
provided "org.apache.commons:commons-lang3:3.6"
|
||||
}
|
|
@ -4,7 +4,7 @@ plugins {
|
|||
}
|
||||
|
||||
bootWar {
|
||||
mainClassName = 'com.example.Application'
|
||||
mainClass = 'com.example.Application'
|
||||
launchScript {
|
||||
properties 'prop' : '{launchScriptProperty}'
|
||||
}
|
||||
|
|
|
@ -4,6 +4,6 @@ plugins {
|
|||
}
|
||||
|
||||
bootWar {
|
||||
mainClassName = 'com.example.Application'
|
||||
mainClass = 'com.example.Application'
|
||||
{launchScript}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,6 @@ plugins {
|
|||
}
|
||||
|
||||
bootWar {
|
||||
mainClassName = 'com.example.Application'
|
||||
mainClass = 'com.example.Application'
|
||||
{launchScript}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
plugins {
|
||||
id 'war'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
plugins {
|
||||
id 'war'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
launchScript()
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
plugins {
|
||||
id 'war'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
if (project.hasProperty('includeLaunchScript') ? includeLaunchScript : false) {
|
||||
launchScript {
|
||||
properties 'prop' : project.hasProperty('launchScriptProperty') ? launchScriptProperty : 'default'
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue