Build with Gradle 7.5 while still supporting Gradle 6.8+

Closes gh-32281
pull/32501/head
Andy Wilkinson 2 years ago
parent 6d0a504283
commit 78f4242e46

@ -38,3 +38,7 @@ allprojects {
resolutionStrategy.cacheChangingModulesFor 0, "minutes" resolutionStrategy.cacheChangingModulesFor 0, "minutes"
} }
} }
tasks.named("checkstyleNohttp").configure {
maxHeapSize = "1g"
}

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import org.gradle.api.attributes.Usage;
import org.gradle.api.component.AdhocComponentWithVariants; import org.gradle.api.component.AdhocComponentWithVariants;
import org.gradle.api.component.ConfigurationVariantDetails; import org.gradle.api.component.ConfigurationVariantDetails;
import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension; import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.publish.PublishingExtension; import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.publish.VariantVersionMappingStrategy; import org.gradle.api.publish.VariantVersionMappingStrategy;
@ -115,9 +114,8 @@ class MavenPublishingConventions {
*/ */
private void addMavenOptionalFeature(Project project) { private void addMavenOptionalFeature(Project project) {
JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class); JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class);
JavaPluginConvention convention = project.getConvention().getPlugin(JavaPluginConvention.class);
extension.registerFeature("mavenOptional", extension.registerFeature("mavenOptional",
(feature) -> feature.usingSourceSet(convention.getSourceSets().getByName("main"))); (feature) -> feature.usingSourceSet(extension.getSourceSets().getByName("main")));
AdhocComponentWithVariants javaComponent = (AdhocComponentWithVariants) project.getComponents() AdhocComponentWithVariants javaComponent = (AdhocComponentWithVariants) project.getComponents()
.findByName("java"); .findByName("java");
javaComponent.addVariantsFromConfiguration( javaComponent.addVariantsFromConfiguration(

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,7 +24,7 @@ import org.gradle.api.Plugin;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Configuration;
import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSet;
import org.springframework.boot.build.DeployedPlugin; import org.springframework.boot.build.DeployedPlugin;
@ -66,7 +66,7 @@ public class AutoConfigurationPlugin implements Plugin<Project> {
.add(project.getDependencies().project(Collections.singletonMap("path", .add(project.getDependencies().project(Collections.singletonMap("path",
":spring-boot-project:spring-boot-tools:spring-boot-configuration-processor"))); ":spring-boot-project:spring-boot-tools:spring-boot-configuration-processor")));
project.getTasks().create("autoConfigurationMetadata", AutoConfigurationMetadata.class, (task) -> { project.getTasks().create("autoConfigurationMetadata", AutoConfigurationMetadata.class, (task) -> {
SourceSet main = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets() SourceSet main = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME); .getByName(SourceSet.MAIN_SOURCE_SET_NAME);
task.setSourceSet(main); task.setSourceSet(main);
task.dependsOn(main.getClassesTaskName()); task.dependsOn(main.getClassesTaskName());

@ -21,8 +21,8 @@ import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import groovy.namespace.QName;
import groovy.util.Node; import groovy.util.Node;
import groovy.xml.QName;
import org.gradle.api.Plugin; import org.gradle.api.Plugin;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Configuration;

@ -16,9 +16,7 @@
package org.springframework.boot.build.context.properties; package org.springframework.boot.build.context.properties;
import java.io.File;
import java.util.Collections; import java.util.Collections;
import java.util.concurrent.Callable;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.gradle.api.Plugin; import org.gradle.api.Plugin;
@ -27,7 +25,7 @@ import org.gradle.api.Task;
import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Configuration;
import org.gradle.api.file.RegularFile; import org.gradle.api.file.RegularFile;
import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.Provider; import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.PathSensitivity;
import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSet;
@ -94,20 +92,19 @@ public class ConfigurationPropertiesPlugin implements Plugin<Project> {
} }
private void disableIncrementalCompilation(Project project) { private void disableIncrementalCompilation(Project project) {
SourceSet mainSourceSet = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets() SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME); .getByName(SourceSet.MAIN_SOURCE_SET_NAME);
project.getTasks().named(mainSourceSet.getCompileJavaTaskName(), JavaCompile.class) project.getTasks().named(mainSourceSet.getCompileJavaTaskName(), JavaCompile.class)
.configure((compileJava) -> compileJava.getOptions().setIncremental(false)); .configure((compileJava) -> compileJava.getOptions().setIncremental(false));
} }
private void addMetadataArtifact(Project project) { private void addMetadataArtifact(Project project) {
SourceSet mainSourceSet = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets() SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME); .getByName(SourceSet.MAIN_SOURCE_SET_NAME);
project.getConfigurations().maybeCreate(CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME); project.getConfigurations().maybeCreate(CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME);
project.afterEvaluate((evaluatedProject) -> evaluatedProject.getArtifacts().add( project.afterEvaluate((evaluatedProject) -> evaluatedProject.getArtifacts().add(
CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME, CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME,
evaluatedProject.provider((Callable<File>) () -> new File(mainSourceSet.getJava().getOutputDir(), mainSourceSet.getJava().getDestinationDirectory().dir("META-INF/spring-configuration-metadata.json"),
"META-INF/spring-configuration-metadata.json")),
(artifact) -> artifact (artifact) -> artifact
.builtBy(evaluatedProject.getTasks().getByName(mainSourceSet.getClassesTaskName())))); .builtBy(evaluatedProject.getTasks().getByName(mainSourceSet.getClassesTaskName()))));
} }
@ -117,7 +114,7 @@ public class ConfigurationPropertiesPlugin implements Plugin<Project> {
.getByName(JavaPlugin.COMPILE_JAVA_TASK_NAME); .getByName(JavaPlugin.COMPILE_JAVA_TASK_NAME);
((Task) compileJava).getInputs().files(project.getTasks().getByName(JavaPlugin.PROCESS_RESOURCES_TASK_NAME)) ((Task) compileJava).getInputs().files(project.getTasks().getByName(JavaPlugin.PROCESS_RESOURCES_TASK_NAME))
.withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("processed resources"); .withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("processed resources");
SourceSet mainSourceSet = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets() SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME); .getByName(SourceSet.MAIN_SOURCE_SET_NAME);
compileJava.getOptions().getCompilerArgs() compileJava.getOptions().getCompilerArgs()
.add("-Aorg.springframework.boot.configurationprocessor.additionalMetadataLocations=" + StringUtils .add("-Aorg.springframework.boot.configurationprocessor.additionalMetadataLocations=" + StringUtils
@ -130,7 +127,7 @@ public class ConfigurationPropertiesPlugin implements Plugin<Project> {
.register(CHECK_ADDITIONAL_SPRING_CONFIGURATION_METADATA_TASK_NAME, .register(CHECK_ADDITIONAL_SPRING_CONFIGURATION_METADATA_TASK_NAME,
CheckAdditionalSpringConfigurationMetadata.class); CheckAdditionalSpringConfigurationMetadata.class);
checkConfigurationMetadata.configure((check) -> { checkConfigurationMetadata.configure((check) -> {
SourceSet mainSourceSet = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets() SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME); .getByName(SourceSet.MAIN_SOURCE_SET_NAME);
check.setSource(mainSourceSet.getResources()); check.setSource(mainSourceSet.getResources());
check.include("META-INF/additional-spring-configuration-metadata.json"); check.include("META-INF/additional-spring-configuration-metadata.json");
@ -145,7 +142,7 @@ public class ConfigurationPropertiesPlugin implements Plugin<Project> {
TaskProvider<CheckSpringConfigurationMetadata> checkConfigurationMetadata = project.getTasks() TaskProvider<CheckSpringConfigurationMetadata> checkConfigurationMetadata = project.getTasks()
.register(CHECK_SPRING_CONFIGURATION_METADATA_TASK_NAME, CheckSpringConfigurationMetadata.class); .register(CHECK_SPRING_CONFIGURATION_METADATA_TASK_NAME, CheckSpringConfigurationMetadata.class);
checkConfigurationMetadata.configure((check) -> { checkConfigurationMetadata.configure((check) -> {
SourceSet mainSourceSet = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets() SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME); .getByName(SourceSet.MAIN_SOURCE_SET_NAME);
Provider<RegularFile> metadataLocation = project.getTasks() Provider<RegularFile> metadataLocation = project.getTasks()
.named(mainSourceSet.getCompileJavaTaskName(), JavaCompile.class) .named(mainSourceSet.getCompileJavaTaskName(), JavaCompile.class)

@ -46,7 +46,7 @@ public class MavenExec extends JavaExec {
public MavenExec() { public MavenExec() {
setClasspath(mavenConfiguration(getProject())); setClasspath(mavenConfiguration(getProject()));
args("--batch-mode"); args("--batch-mode");
setMain("org.apache.maven.cli.MavenCli"); getMainClass().set("org.apache.maven.cli.MavenCli");
} }
public void setProjectDir(File projectDir) { public void setProjectDir(File projectDir) {

@ -64,7 +64,7 @@ import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.model.ObjectFactory; import org.gradle.api.model.ObjectFactory;
import org.gradle.api.plugins.JavaLibraryPlugin; import org.gradle.api.plugins.JavaLibraryPlugin;
import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.publish.PublishingExtension; import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.publish.maven.MavenPublication; import org.gradle.api.publish.maven.MavenPublication;
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin; import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
@ -225,7 +225,7 @@ public class MavenPluginPlugin implements Plugin<Project> {
} }
private SourceSet getMainSourceSet(Project project) { private SourceSet getMainSourceSet(Project project) {
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets(); SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
return sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); return sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,7 +20,7 @@ import org.gradle.api.Plugin;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Configuration;
import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.SourceSetContainer;
/** /**
@ -44,7 +44,7 @@ public class OptionalDependenciesPlugin implements Plugin<Project> {
optional.setCanBeConsumed(false); optional.setCanBeConsumed(false);
optional.setCanBeResolved(false); optional.setCanBeResolved(false);
project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> { project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> {
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class) SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class)
.getSourceSets(); .getSourceSets();
sourceSets.all((sourceSet) -> { sourceSets.all((sourceSet) -> {
project.getConfigurations().getByName(sourceSet.getCompileClasspathConfigurationName()) project.getConfigurations().getByName(sourceSet.getCompileClasspathConfigurationName())

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,7 @@ package org.springframework.boot.build.test;
import org.gradle.api.Plugin; import org.gradle.api.Plugin;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.testing.Test; import org.gradle.api.tasks.testing.Test;
@ -61,7 +61,7 @@ public class IntegrationTestPlugin implements Plugin<Project> {
} }
private SourceSet createSourceSet(Project project) { private SourceSet createSourceSet(Project project) {
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets(); SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
SourceSet intTestSourceSet = sourceSets.create(INT_TEST_SOURCE_SET_NAME); SourceSet intTestSourceSet = sourceSets.create(INT_TEST_SOURCE_SET_NAME);
SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
intTestSourceSet.setCompileClasspath(intTestSourceSet.getCompileClasspath().plus(main.getOutput())); intTestSourceSet.setCompileClasspath(intTestSourceSet.getCompileClasspath().plus(main.getOutput()));

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,7 +20,7 @@ import org.gradle.api.Plugin;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.Task; import org.gradle.api.Task;
import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.specs.Spec; import org.gradle.api.specs.Spec;
import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.SourceSetContainer;
@ -65,7 +65,7 @@ public class SystemTestPlugin implements Plugin<Project> {
} }
private SourceSet createSourceSet(Project project) { private SourceSet createSourceSet(Project project) {
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets(); SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
SourceSet systemTestSourceSet = sourceSets.create(SYSTEM_TEST_SOURCE_SET_NAME); SourceSet systemTestSourceSet = sourceSets.create(SYSTEM_TEST_SOURCE_SET_NAME);
SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
systemTestSourceSet systemTestSourceSet

Binary file not shown.

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

6
gradlew vendored

@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \ org.gradle.wrapper.GradleWrapperMain \
"$@" "$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args. # Use "xargs" to parse quoted args.
# #
# With -n1 it outputs one arg per line, with the quotes and backslashes removed. # With -n1 it outputs one arg per line, with the quotes and backslashes removed.

14
gradlew.bat vendored

@ -14,7 +14,7 @@
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute if %ERRORLEVEL% equ 0 goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd if %ERRORLEVEL% equ 0 goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 set EXIT_CODE=%ERRORLEVEL%
exit /b 1 if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd :mainEnd
if "%OS%"=="Windows_NT" endlocal if "%OS%"=="Windows_NT" endlocal

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -187,7 +187,10 @@ class ThreadDumpEndpointDocumentationTests extends MockMvcEndpointDocumentationT
.andDo(MockMvcRestDocumentation.document("threaddump/text", .andDo(MockMvcRestDocumentation.document("threaddump/text",
preprocessResponse(new ContentModifyingOperationPreprocessor((bytes, mediaType) -> { preprocessResponse(new ContentModifyingOperationPreprocessor((bytes, mediaType) -> {
String content = new String(bytes, StandardCharsets.UTF_8); String content = new String(bytes, StandardCharsets.UTF_8);
return content.substring(0, content.indexOf("\"main\" - Thread")).getBytes(); int mainThreadIndex = content.indexOf("\"main\" - Thread");
String truncatedContent = (mainThreadIndex >= 0) ? content.substring(0, mainThreadIndex)
: content;
return truncatedContent.getBytes();
})))); }))));
} }

@ -205,4 +205,9 @@ bom {
dependencies { dependencies {
api(enforcedPlatform(project(":spring-boot-project:spring-boot-dependencies"))) api(enforcedPlatform(project(":spring-boot-project:spring-boot-dependencies")))
} }
tasks.withType(GenerateModuleMetadata).configureEach {
// Internal module so enforced platform dependencies are OK
suppressedValidationErrors.add('enforced-platform')
}

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,9 +22,9 @@ import org.gradle.api.Action;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.plugins.BasePlugin; import org.gradle.api.plugins.BasePlugin;
import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.provider.Property; import org.gradle.api.provider.Property;
import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.TaskContainer; import org.gradle.api.tasks.TaskContainer;
import org.gradle.api.tasks.TaskProvider; import org.gradle.api.tasks.TaskProvider;
import org.gradle.jvm.tasks.Jar; import org.gradle.jvm.tasks.Jar;
@ -112,8 +112,12 @@ public class SpringBootExtension {
} }
private File determineMainSourceSetResourcesOutputDir() { private File determineMainSourceSetResourcesOutputDir() {
return this.project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets() return sourceSets(this.project).getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput().getResourcesDir();
.getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput().getResourcesDir(); }
@SuppressWarnings("deprecation")
private SourceSetContainer sourceSets(Project project) {
return project.getConvention().getPlugin(org.gradle.api.plugins.JavaPluginConvention.class).getSourceSets();
} }
private String determineArtifactBaseName() { private String determineArtifactBaseName() {

@ -31,7 +31,7 @@ import org.gradle.api.distribution.DistributionContainer;
import org.gradle.api.file.CopySpec; import org.gradle.api.file.CopySpec;
import org.gradle.api.file.FileCollection; import org.gradle.api.file.FileCollection;
import org.gradle.api.plugins.ApplicationPlugin; import org.gradle.api.plugins.ApplicationPlugin;
import org.gradle.api.plugins.ApplicationPluginConvention; import org.gradle.api.plugins.JavaApplication;
import org.gradle.api.tasks.TaskProvider; import org.gradle.api.tasks.TaskProvider;
import org.gradle.jvm.application.scripts.TemplateBasedScriptGenerator; import org.gradle.jvm.application.scripts.TemplateBasedScriptGenerator;
import org.gradle.jvm.application.tasks.CreateStartScripts; import org.gradle.jvm.application.tasks.CreateStartScripts;
@ -45,21 +45,20 @@ final class ApplicationPluginAction implements PluginApplicationAction {
@Override @Override
public void execute(Project project) { public void execute(Project project) {
ApplicationPluginConvention applicationConvention = project.getConvention() JavaApplication javaApplication = project.getExtensions().getByType(JavaApplication.class);
.getPlugin(ApplicationPluginConvention.class);
DistributionContainer distributions = project.getExtensions().getByType(DistributionContainer.class); DistributionContainer distributions = project.getExtensions().getByType(DistributionContainer.class);
Distribution distribution = distributions.create("boot"); Distribution distribution = distributions.create("boot");
distribution.getDistributionBaseName() distribution.getDistributionBaseName()
.convention((project.provider(() -> applicationConvention.getApplicationName() + "-boot"))); .convention((project.provider(() -> javaApplication.getApplicationName() + "-boot")));
TaskProvider<CreateStartScripts> bootStartScripts = project.getTasks().register("bootStartScripts", TaskProvider<CreateStartScripts> bootStartScripts = project.getTasks().register("bootStartScripts",
CreateStartScripts.class, CreateStartScripts.class,
(task) -> configureCreateStartScripts(project, applicationConvention, distribution, task)); (task) -> configureCreateStartScripts(project, javaApplication, distribution, task));
CopySpec binCopySpec = project.copySpec().into("bin").from(bootStartScripts); CopySpec binCopySpec = project.copySpec().into("bin").from(bootStartScripts);
binCopySpec.setFileMode(0755); binCopySpec.setFileMode(0755);
distribution.getContents().with(binCopySpec); distribution.getContents().with(binCopySpec);
} }
private void configureCreateStartScripts(Project project, ApplicationPluginConvention applicationConvention, private void configureCreateStartScripts(Project project, JavaApplication javaApplication,
Distribution distribution, CreateStartScripts createStartScripts) { Distribution distribution, CreateStartScripts createStartScripts) {
createStartScripts createStartScripts
.setDescription("Generates OS-specific start scripts to run the project as a Spring Boot application."); .setDescription("Generates OS-specific start scripts to run the project as a Spring Boot application.");
@ -75,9 +74,8 @@ final class ApplicationPluginAction implements PluginApplicationAction {
}); });
createStartScripts.getConventionMapping().map("outputDir", createStartScripts.getConventionMapping().map("outputDir",
() -> new File(project.getBuildDir(), "bootScripts")); () -> new File(project.getBuildDir(), "bootScripts"));
createStartScripts.getConventionMapping().map("applicationName", applicationConvention::getApplicationName); createStartScripts.getConventionMapping().map("applicationName", javaApplication::getApplicationName);
createStartScripts.getConventionMapping().map("defaultJvmOpts", createStartScripts.getConventionMapping().map("defaultJvmOpts", javaApplication::getApplicationDefaultJvmArgs);
applicationConvention::getApplicationDefaultJvmArgs);
} }
private CopySpec artifactFilesToLibCopySpec(Project project, Configuration configuration) { private CopySpec artifactFilesToLibCopySpec(Project project, Configuration configuration) {

@ -36,7 +36,6 @@ import org.gradle.api.model.ObjectFactory;
import org.gradle.api.plugins.ApplicationPlugin; import org.gradle.api.plugins.ApplicationPlugin;
import org.gradle.api.plugins.BasePlugin; import org.gradle.api.plugins.BasePlugin;
import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension; import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.Provider; import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSet;
@ -98,8 +97,7 @@ final class JavaPluginAction implements PluginApplicationAction {
} }
private TaskProvider<BootJar> configureBootJarTask(Project project) { private TaskProvider<BootJar> configureBootJarTask(Project project) {
SourceSet mainSourceSet = javaPluginConvention(project).getSourceSets() SourceSet mainSourceSet = sourceSets(project).getByName(SourceSet.MAIN_SOURCE_SET_NAME);
.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
Configuration developmentOnly = project.getConfigurations() Configuration developmentOnly = project.getConfigurations()
.getByName(SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME); .getByName(SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME);
Configuration productionRuntimeClasspath = project.getConfigurations() Configuration productionRuntimeClasspath = project.getConfigurations()
@ -125,8 +123,8 @@ final class JavaPluginAction implements PluginApplicationAction {
buildImage.setDescription("Builds an OCI image of the application using the output of the bootJar task"); buildImage.setDescription("Builds an OCI image of the application using the output of the bootJar task");
buildImage.setGroup(BasePlugin.BUILD_GROUP); buildImage.setGroup(BasePlugin.BUILD_GROUP);
buildImage.getArchiveFile().set(bootJar.get().getArchiveFile()); buildImage.getArchiveFile().set(bootJar.get().getArchiveFile());
buildImage.getTargetJavaVersion() buildImage.getTargetJavaVersion().set(project.provider(
.set(project.provider(() -> javaPluginConvention(project).getTargetCompatibility())); () -> project.getExtensions().getByType(JavaPluginExtension.class).getTargetCompatibility()));
}); });
} }
@ -135,8 +133,8 @@ final class JavaPluginAction implements PluginApplicationAction {
} }
private void configureBootRunTask(Project project) { private void configureBootRunTask(Project project) {
Callable<FileCollection> classpath = () -> javaPluginConvention(project).getSourceSets() Callable<FileCollection> classpath = () -> sourceSets(project).findByName(SourceSet.MAIN_SOURCE_SET_NAME)
.findByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath().filter(new JarTypeFileSpec()); .getRuntimeClasspath().filter(new JarTypeFileSpec());
TaskProvider<ResolveMainClassName> resolveProvider = ResolveMainClassName.registerForTask("bootRun", project, TaskProvider<ResolveMainClassName> resolveProvider = ResolveMainClassName.registerForTask("bootRun", project,
classpath); classpath);
project.getTasks().register("bootRun", BootRun.class, (run) -> { project.getTasks().register("bootRun", BootRun.class, (run) -> {
@ -160,8 +158,9 @@ final class JavaPluginAction implements PluginApplicationAction {
run.getJavaLauncher().convention(toolchainService.launcherFor(toolchain)); run.getJavaLauncher().convention(toolchainService.launcherFor(toolchain));
} }
private JavaPluginConvention javaPluginConvention(Project project) { @SuppressWarnings("deprecation")
return project.getConvention().getPlugin(JavaPluginConvention.class); private SourceSetContainer sourceSets(Project project) {
return project.getConvention().getPlugin(org.gradle.api.plugins.JavaPluginConvention.class).getSourceSets();
} }
private void configureUtf8Encoding(Project evaluatedProject) { private void configureUtf8Encoding(Project evaluatedProject) {
@ -189,9 +188,8 @@ final class JavaPluginAction implements PluginApplicationAction {
} }
private void configureAdditionalMetadataLocations(JavaCompile compile) { private void configureAdditionalMetadataLocations(JavaCompile compile) {
SourceSetContainer sourceSets = compile.getProject().getConvention().getPlugin(JavaPluginConvention.class) sourceSets(compile.getProject()).stream()
.getSourceSets(); .filter((candidate) -> candidate.getCompileJavaTaskName().equals(compile.getName()))
sourceSets.stream().filter((candidate) -> candidate.getCompileJavaTaskName().equals(compile.getName()))
.map((match) -> match.getResources().getSrcDirs()).findFirst() .map((match) -> match.getResources().getSrcDirs()).findFirst()
.ifPresent((locations) -> compile.doFirst(new AdditionalMetadataLocationsConfigurer(locations))); .ifPresent((locations) -> compile.doFirst(new AdditionalMetadataLocationsConfigurer(locations)));
} }

@ -17,10 +17,11 @@
package org.springframework.boot.gradle.plugin; package org.springframework.boot.gradle.plugin;
import org.gradle.api.Action; import org.gradle.api.Action;
import org.gradle.api.GradleException;
import org.gradle.api.Plugin; import org.gradle.api.Plugin;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.artifacts.repositories.ArtifactRepository;
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin; import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
import org.gradle.api.tasks.Upload;
/** /**
* {@link Action} that is executed in response to the * {@link Action} that is executed in response to the
@ -46,7 +47,7 @@ final class MavenPluginAction implements PluginApplicationAction {
@Override @Override
public void execute(Project project) { public void execute(Project project) {
project.afterEvaluate((evaluated) -> { project.afterEvaluate((evaluated) -> {
project.getTasks().withType(Upload.class).configureEach((upload) -> { project.getTasks().withType(org.gradle.api.tasks.Upload.class).configureEach((upload) -> {
if (this.uploadTaskName.equals(upload.getName())) { if (this.uploadTaskName.equals(upload.getName())) {
clearConfigurationMappings(upload); clearConfigurationMappings(upload);
} }
@ -54,9 +55,28 @@ final class MavenPluginAction implements PluginApplicationAction {
}); });
} }
private void clearConfigurationMappings(Upload upload) { private void clearConfigurationMappings(org.gradle.api.tasks.Upload upload) {
upload.getRepositories().withType(org.gradle.api.artifacts.maven.MavenResolver.class, upload.getRepositories().matching(this::isMavenResolver).all((resolver) -> {
(resolver) -> resolver.getPom().getScopeMappings().getMappings().clear()); try {
Object pom = resolver.getClass().getMethod("getPom").invoke(resolver);
Object scopeMappings = pom.getClass().getMethod("getScopeMappings").invoke(pom);
Object mappings = scopeMappings.getClass().getMethod("getMappings").invoke(scopeMappings);
mappings.getClass().getMethod("clear").invoke(mappings);
}
catch (Exception ex) {
throw new GradleException("Failed to clear configuration mappings for task '" + upload.getName() + "'",
ex);
}
});
}
private boolean isMavenResolver(ArtifactRepository repository) {
for (Class<?> iface : repository.getClass().getInterfaces()) {
if ("org.gradle.api.artifacts.maven.GroovyMavenDeployer".equals(iface.getName())) {
return true;
}
}
return false;
} }
} }

@ -34,7 +34,6 @@ import org.gradle.api.file.FileCollection;
import org.gradle.api.file.RegularFile; import org.gradle.api.file.RegularFile;
import org.gradle.api.file.RegularFileProperty; import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.plugins.BasePlugin; import org.gradle.api.plugins.BasePlugin;
import org.gradle.api.plugins.Convention;
import org.gradle.api.plugins.JavaApplication; import org.gradle.api.plugins.JavaApplication;
import org.gradle.api.provider.Property; import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider; import org.gradle.api.provider.Provider;
@ -44,6 +43,7 @@ import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.OutputFile; import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction; import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.TaskProvider; import org.gradle.api.tasks.TaskProvider;
import org.gradle.work.DisableCachingByDefault;
import org.springframework.boot.gradle.dsl.SpringBootExtension; import org.springframework.boot.gradle.dsl.SpringBootExtension;
import org.springframework.boot.loader.tools.MainClassFinder; import org.springframework.boot.loader.tools.MainClassFinder;
@ -54,6 +54,7 @@ import org.springframework.boot.loader.tools.MainClassFinder;
* @author Andy Wilkinson * @author Andy Wilkinson
* @since 2.4 * @since 2.4
*/ */
@DisableCachingByDefault(because = "Not worth caching")
public class ResolveMainClassName extends DefaultTask { public class ResolveMainClassName extends DefaultTask {
private static final String SPRING_BOOT_APPLICATION_CLASS_NAME = "org.springframework.boot.autoconfigure.SpringBootApplication"; private static final String SPRING_BOOT_APPLICATION_CLASS_NAME = "org.springframework.boot.autoconfigure.SpringBootApplication";
@ -156,13 +157,12 @@ public class ResolveMainClassName extends DefaultTask {
Callable<FileCollection> classpath) { Callable<FileCollection> classpath) {
TaskProvider<ResolveMainClassName> resolveMainClassNameProvider = project.getTasks() TaskProvider<ResolveMainClassName> resolveMainClassNameProvider = project.getTasks()
.register(taskName + "MainClassName", ResolveMainClassName.class, (resolveMainClassName) -> { .register(taskName + "MainClassName", ResolveMainClassName.class, (resolveMainClassName) -> {
Convention convention = project.getConvention();
resolveMainClassName.setDescription( resolveMainClassName.setDescription(
"Resolves the name of the application's main class for the " + taskName + " task."); "Resolves the name of the application's main class for the " + taskName + " task.");
resolveMainClassName.setGroup(BasePlugin.BUILD_GROUP); resolveMainClassName.setGroup(BasePlugin.BUILD_GROUP);
resolveMainClassName.setClasspath(classpath); resolveMainClassName.setClasspath(classpath);
resolveMainClassName.getConfiguredMainClassName().convention(project.provider(() -> { resolveMainClassName.getConfiguredMainClassName().convention(project.provider(() -> {
String javaApplicationMainClass = getJavaApplicationMainClass(convention); String javaApplicationMainClass = getJavaApplicationMainClass(project);
if (javaApplicationMainClass != null) { if (javaApplicationMainClass != null) {
return javaApplicationMainClass; return javaApplicationMainClass;
} }
@ -176,8 +176,8 @@ public class ResolveMainClassName extends DefaultTask {
return resolveMainClassNameProvider; return resolveMainClassNameProvider;
} }
private static String getJavaApplicationMainClass(Convention convention) { private static String getJavaApplicationMainClass(Project project) {
JavaApplication javaApplication = convention.findByType(JavaApplication.class); JavaApplication javaApplication = project.getExtensions().findByType(JavaApplication.class);
if (javaApplication == null) { if (javaApplication == null) {
return null; return null;
} }

@ -72,10 +72,9 @@ class WarPluginAction implements PluginApplicationAction {
.getByName(SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME); .getByName(SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME);
Configuration productionRuntimeClasspath = project.getConfigurations() Configuration productionRuntimeClasspath = project.getConfigurations()
.getByName(SpringBootPlugin.PRODUCTION_RUNTIME_CLASSPATH_CONFIGURATION_NAME); .getByName(SpringBootPlugin.PRODUCTION_RUNTIME_CLASSPATH_CONFIGURATION_NAME);
Callable<FileCollection> classpath = () -> project.getConvention().getByType(SourceSetContainer.class) Callable<FileCollection> classpath = () -> sourceSets(project).getByName(SourceSet.MAIN_SOURCE_SET_NAME)
.getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath() .getRuntimeClasspath().minus(providedRuntimeConfiguration(project))
.minus(providedRuntimeConfiguration(project)).minus((developmentOnly.minus(productionRuntimeClasspath))) .minus((developmentOnly.minus(productionRuntimeClasspath))).filter(new JarTypeFileSpec());
.filter(new JarTypeFileSpec());
TaskProvider<ResolveMainClassName> resolveMainClassName = ResolveMainClassName TaskProvider<ResolveMainClassName> resolveMainClassName = ResolveMainClassName
.registerForTask(SpringBootPlugin.BOOT_WAR_TASK_NAME, project, classpath); .registerForTask(SpringBootPlugin.BOOT_WAR_TASK_NAME, project, classpath);
TaskProvider<BootWar> bootWarProvider = project.getTasks().register(SpringBootPlugin.BOOT_WAR_TASK_NAME, TaskProvider<BootWar> bootWarProvider = project.getTasks().register(SpringBootPlugin.BOOT_WAR_TASK_NAME,
@ -95,6 +94,11 @@ class WarPluginAction implements PluginApplicationAction {
return bootWarProvider; return bootWarProvider;
} }
@SuppressWarnings("deprecation")
private SourceSetContainer sourceSets(Project project) {
return project.getConvention().getPlugin(org.gradle.api.plugins.JavaPluginConvention.class).getSourceSets();
}
private FileCollection providedRuntimeConfiguration(Project project) { private FileCollection providedRuntimeConfiguration(Project project) {
ConfigurationContainer configurations = project.getConfigurations(); ConfigurationContainer configurations = project.getConfigurations();
return configurations.getByName(WarPlugin.PROVIDED_RUNTIME_CONFIGURATION_NAME); return configurations.getByName(WarPlugin.PROVIDED_RUNTIME_CONFIGURATION_NAME);

@ -30,6 +30,7 @@ import org.gradle.api.tasks.Nested;
import org.gradle.api.tasks.OutputDirectory; import org.gradle.api.tasks.OutputDirectory;
import org.gradle.api.tasks.TaskAction; import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.TaskExecutionException; import org.gradle.api.tasks.TaskExecutionException;
import org.gradle.work.DisableCachingByDefault;
import org.springframework.boot.loader.tools.BuildPropertiesWriter; import org.springframework.boot.loader.tools.BuildPropertiesWriter;
import org.springframework.boot.loader.tools.BuildPropertiesWriter.ProjectDetails; import org.springframework.boot.loader.tools.BuildPropertiesWriter.ProjectDetails;
@ -41,6 +42,7 @@ import org.springframework.boot.loader.tools.BuildPropertiesWriter.ProjectDetail
* @author Andy Wilkinson * @author Andy Wilkinson
* @since 2.0.0 * @since 2.0.0
*/ */
@DisableCachingByDefault(because = "Not worth caching")
public class BuildInfo extends ConventionTask { public class BuildInfo extends ConventionTask {
private final BuildInfoProperties properties = new BuildInfoProperties(getProject()); private final BuildInfoProperties properties = new BuildInfoProperties(getProject());

@ -66,12 +66,17 @@ public class BuildInfoProperties implements Serializable {
} }
private Provider<String> projectVersion(Project project) { private Provider<String> projectVersion(Project project) {
Provider<String> externalVersionProperty = project.getProviders().gradleProperty("version") Provider<String> externalVersionProperty = forUseAtConfigurationTime(
.forUseAtConfigurationTime(); project.getProviders().gradleProperty("version"));
externalVersionProperty.getOrNull(); externalVersionProperty.getOrNull();
return project.provider(() -> project.getVersion().toString()); return project.provider(() -> project.getVersion().toString());
} }
@SuppressWarnings("deprecation")
private Provider<String> forUseAtConfigurationTime(Provider<String> provider) {
return provider.forUseAtConfigurationTime();
}
/** /**
* Returns the value used for the {@code build.group} property. Defaults to the * Returns the value used for the {@code build.group} property. Defaults to the
* {@link Project#getGroup() Project's group}. * {@link Project#getGroup() Project's group}.

@ -36,7 +36,7 @@ import org.gradle.api.tasks.Nested;
import org.gradle.api.tasks.Optional; import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.TaskAction; import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.options.Option; import org.gradle.api.tasks.options.Option;
import org.gradle.util.ConfigureUtil; import org.gradle.work.DisableCachingByDefault;
import org.springframework.boot.buildpack.platform.build.BuildRequest; import org.springframework.boot.buildpack.platform.build.BuildRequest;
import org.springframework.boot.buildpack.platform.build.Builder; import org.springframework.boot.buildpack.platform.build.Builder;
@ -62,6 +62,7 @@ import org.springframework.util.StringUtils;
* @author Julian Liebig * @author Julian Liebig
* @since 2.3.0 * @since 2.3.0
*/ */
@DisableCachingByDefault
public class BootBuildImage extends DefaultTask { public class BootBuildImage extends DefaultTask {
private static final String BUILDPACK_JVM_VERSION_KEY = "BP_JVM_VERSION"; private static final String BUILDPACK_JVM_VERSION_KEY = "BP_JVM_VERSION";
@ -465,7 +466,7 @@ public class BootBuildImage extends DefaultTask {
* @param closure the closure * @param closure the closure
*/ */
public void buildCache(Closure<?> closure) { public void buildCache(Closure<?> closure) {
buildCache(ConfigureUtil.configureUsing(closure)); buildCache(Closures.asAction(closure));
} }
/** /**
@ -493,7 +494,7 @@ public class BootBuildImage extends DefaultTask {
* @param closure the closure * @param closure the closure
*/ */
public void launchCache(Closure<?> closure) { public void launchCache(Closure<?> closure) {
launchCache(ConfigureUtil.configureUsing(closure)); launchCache(Closures.asAction(closure));
} }
/** /**
@ -521,7 +522,7 @@ public class BootBuildImage extends DefaultTask {
* @since 2.4.0 * @since 2.4.0
*/ */
public void docker(Closure<?> closure) { public void docker(Closure<?> closure) {
docker(ConfigureUtil.configureUsing(closure)); docker(Closures.asAction(closure));
} }
@TaskAction @TaskAction

@ -34,6 +34,7 @@ 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.bundling.Jar; import org.gradle.api.tasks.bundling.Jar;
import org.gradle.work.DisableCachingByDefault;
/** /**
* A custom {@link Jar} task that produces a Spring Boot executable jar. * A custom {@link Jar} task that produces a Spring Boot executable jar.
@ -44,6 +45,7 @@ import org.gradle.api.tasks.bundling.Jar;
* @author Phillip Webb * @author Phillip Webb
* @since 2.0.0 * @since 2.0.0
*/ */
@DisableCachingByDefault(because = "Not worth caching")
public class BootJar extends Jar implements BootArchive { public class BootJar extends Jar implements BootArchive {
private static final String LAUNCHER = "org.springframework.boot.loader.JarLauncher"; private static final String LAUNCHER = "org.springframework.boot.loader.JarLauncher";

@ -35,6 +35,7 @@ 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.Optional;
import org.gradle.api.tasks.bundling.War; import org.gradle.api.tasks.bundling.War;
import org.gradle.work.DisableCachingByDefault;
/** /**
* A custom {@link War} task that produces a Spring Boot executable war. * A custom {@link War} task that produces a Spring Boot executable war.
@ -43,6 +44,7 @@ import org.gradle.api.tasks.bundling.War;
* @author Phillip Webb * @author Phillip Webb
* @since 2.0.0 * @since 2.0.0
*/ */
@DisableCachingByDefault(because = "Not worth caching")
public class BootWar extends War implements BootArchive { public class BootWar extends War implements BootArchive {
private static final String LAUNCHER = "org.springframework.boot.loader.WarLauncher"; private static final String LAUNCHER = "org.springframework.boot.loader.WarLauncher";

@ -1,5 +1,5 @@
/* /*
* Copyright 2021-2021 the original author or authors. * Copyright 2021-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,7 +20,6 @@ import groovy.lang.Closure;
import org.gradle.api.Action; import org.gradle.api.Action;
import org.gradle.api.GradleException; import org.gradle.api.GradleException;
import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Input;
import org.gradle.util.ConfigureUtil;
import org.springframework.boot.buildpack.platform.build.Cache; import org.springframework.boot.buildpack.platform.build.Cache;
@ -62,7 +61,7 @@ public class CacheSpec {
if (this.cache != null) { if (this.cache != null) {
throw new GradleException("Each image building cache can be configured only once"); throw new GradleException("Each image building cache can be configured only once");
} }
volume(ConfigureUtil.configureUsing(closure)); volume(Closures.asAction(closure));
} }
/** /**

@ -0,0 +1,39 @@
/*
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.gradle.tasks.bundling;
import groovy.lang.Closure;
import org.gradle.api.Action;
/**
* Wrapper for the deprecated {@link org.gradle.util.ConfigureUtil} that allows
* deprecation warnings to be suppressed in a single, focused location.
*
* @author Andy Wilkinson
*/
final class Closures {
private Closures() {
}
@SuppressWarnings("deprecation")
static <T> Action<T> asAction(Closure<?> closure) {
return org.gradle.util.ConfigureUtil.configureUsing(closure);
}
}

@ -22,7 +22,6 @@ import org.gradle.api.GradleException;
import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Nested; import org.gradle.api.tasks.Nested;
import org.gradle.api.tasks.Optional; import org.gradle.api.tasks.Optional;
import org.gradle.util.ConfigureUtil;
import org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration; import org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration;
@ -110,7 +109,7 @@ public class DockerSpec {
* @param closure the closure to apply * @param closure the closure to apply
*/ */
public void builderRegistry(Closure<?> closure) { public void builderRegistry(Closure<?> closure) {
builderRegistry(ConfigureUtil.configureUsing(closure)); builderRegistry(Closures.asAction(closure));
} }
/** /**
@ -138,7 +137,7 @@ public class DockerSpec {
* @param closure the closure to apply * @param closure the closure to apply
*/ */
public void publishRegistry(Closure<?> closure) { public void publishRegistry(Closure<?> closure) {
publishRegistry(ConfigureUtil.configureUsing(closure)); publishRegistry(Closures.asAction(closure));
} }
/** /**

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +27,6 @@ import groovy.lang.Closure;
import org.gradle.api.Action; import org.gradle.api.Action;
import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Optional; import org.gradle.api.tasks.Optional;
import org.gradle.util.ConfigureUtil;
import org.springframework.boot.loader.tools.Layer; import org.springframework.boot.loader.tools.Layer;
import org.springframework.boot.loader.tools.Layers; import org.springframework.boot.loader.tools.Layers;
@ -133,7 +132,7 @@ public class LayeredSpec {
* @param closure the closure * @param closure the closure
*/ */
public void application(Closure<?> closure) { public void application(Closure<?> closure) {
application(ConfigureUtil.configureUsing(closure)); application(Closures.asAction(closure));
} }
/** /**
@ -168,7 +167,7 @@ public class LayeredSpec {
* @param closure the closure * @param closure the closure
*/ */
public void dependencies(Closure<?> closure) { public void dependencies(Closure<?> closure) {
dependencies(ConfigureUtil.configureUsing(closure)); dependencies(Closures.asAction(closure));
} }
/** /**
@ -245,7 +244,7 @@ public class LayeredSpec {
} }
public void intoLayer(String layer, Closure<?> closure) { public void intoLayer(String layer, Closure<?> closure) {
intoLayer(layer, ConfigureUtil.configureUsing(closure)); intoLayer(layer, Closures.asAction(closure));
} }
public void intoLayer(String layer, Action<IntoLayerSpec> action) { public void intoLayer(String layer, Action<IntoLayerSpec> action) {

@ -27,6 +27,7 @@ import org.gradle.api.tasks.JavaExec;
import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetOutput; import org.gradle.api.tasks.SourceSetOutput;
import org.gradle.jvm.toolchain.JavaLauncher; import org.gradle.jvm.toolchain.JavaLauncher;
import org.gradle.work.DisableCachingByDefault;
/** /**
* Custom {@link JavaExec} task for running a Spring Boot application. * Custom {@link JavaExec} task for running a Spring Boot application.
@ -34,6 +35,7 @@ import org.gradle.jvm.toolchain.JavaLauncher;
* @author Andy Wilkinson * @author Andy Wilkinson
* @since 2.0.0 * @since 2.0.0
*/ */
@DisableCachingByDefault(because = "Application should always run")
public class BootRun extends JavaExec { public class BootRun extends JavaExec {
private boolean optimizedLaunch = true; private boolean optimizedLaunch = true;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -61,7 +61,7 @@ public class GradleMultiDslExtension implements TestTemplateInvocationContextPro
@Override @Override
public List<Extension> getAdditionalExtensions() { public List<Extension> getAdditionalExtensions() {
GradleBuild gradleBuild = new GradleBuild(this.dsl); GradleBuild gradleBuild = new GradleBuild(this.dsl);
gradleBuild.gradleVersion(GradleVersions.currentOrMinimumCompatible()); gradleBuild.gradleVersion(GradleVersions.minimumCompatible());
return Arrays.asList(new GradleBuildFieldSetter(gradleBuild), new GradleBuildExtension()); return Arrays.asList(new GradleBuildFieldSetter(gradleBuild), new GradleBuildExtension());
} }

@ -68,7 +68,7 @@ public final class GradleProjectBuilder {
builder.withName(this.name); builder.withName(this.name);
} }
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) { if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
NativeServices.initialize(userHome); NativeServices.initializeOnClient(userHome);
try { try {
ProjectBuilderImpl.getGlobalServices(); ProjectBuilderImpl.getGlobalServices();
} }

@ -34,30 +34,24 @@ public final class GradleVersions {
public static List<String> allCompatible() { public static List<String> allCompatible() {
if (isJava18()) { if (isJava18()) {
return Arrays.asList("7.3.3", "7.4.2", "7.5.1"); return Arrays.asList("7.3.3", "7.4.2", GradleVersion.current().getVersion());
} }
if (isJava17()) { if (isJava17()) {
return Arrays.asList("7.2", "7.3.3", "7.4.2", "7.5.1"); return Arrays.asList("7.2", "7.3.3", "7.4.2", GradleVersion.current().getVersion());
} }
if (isJava16()) { if (isJava16()) {
return Arrays.asList("7.0.2", "7.1", "7.2", "7.3.3", "7.4.2", "7.5.1"); return Arrays.asList("7.0.2", "7.1", "7.2", "7.3.3", "7.4.2", GradleVersion.current().getVersion());
} }
return Arrays.asList("6.8.3", GradleVersion.current().getVersion(), "7.0.2", "7.1.1", "7.2", "7.3.3", "7.4.2", return Arrays.asList("6.8.3", "6.9.2", "7.0.2", "7.1.1", "7.2", "7.3.3", "7.4.2",
"7.5.1"); GradleVersion.current().getVersion());
} }
public static String currentOrMinimumCompatible() { public static String minimumCompatible() {
if (isJava17()) { return allCompatible().get(0);
return "7.3.3";
}
if (isJava16()) {
return "7.0.2";
}
return GradleVersion.current().getVersion();
} }
private static boolean isJava18() { private static boolean isJava18() {
return JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_HIGHER); return JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_18);
} }
private static boolean isJava17() { private static boolean isJava17() {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -38,7 +38,7 @@ public class GradleBuildInjectionExtension implements BeforeEachCallback {
GradleBuildInjectionExtension() { GradleBuildInjectionExtension() {
this.gradleBuild = new GradleBuild(); this.gradleBuild = new GradleBuild();
this.gradleBuild.gradleVersion(GradleVersions.currentOrMinimumCompatible()); this.gradleBuild.gradleVersion(GradleVersions.minimumCompatible());
String bootVersion = System.getProperty("springBootVersion"); String bootVersion = System.getProperty("springBootVersion");
Assert.notNull(bootVersion, "Property 'springBootVersion' must be set in build environment"); Assert.notNull(bootVersion, "Property 'springBootVersion' must be set in build environment");
this.gradleBuild.bootVersion(bootVersion); this.gradleBuild.bootVersion(bootVersion);

Loading…
Cancel
Save