Skip to content

Commit 78f4242

Browse files
committed
Build with Gradle 7.5 while still supporting Gradle 6.8+
Closes gh-32281
1 parent 6d0a504 commit 78f4242

File tree

36 files changed

+198
-115
lines changed

36 files changed

+198
-115
lines changed

build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ allprojects {
3838
resolutionStrategy.cacheChangingModulesFor 0, "minutes"
3939
}
4040
}
41+
42+
tasks.named("checkstyleNohttp").configure {
43+
maxHeapSize = "1g"
44+
}

buildSrc/src/main/java/org/springframework/boot/build/MavenPublishingConventions.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
2222
import org.gradle.api.component.AdhocComponentWithVariants;
2323
import org.gradle.api.component.ConfigurationVariantDetails;
2424
import org.gradle.api.plugins.JavaPlugin;
25-
import org.gradle.api.plugins.JavaPluginConvention;
2625
import org.gradle.api.plugins.JavaPluginExtension;
2726
import org.gradle.api.publish.PublishingExtension;
2827
import org.gradle.api.publish.VariantVersionMappingStrategy;
@@ -115,9 +114,8 @@ private void customizeJavaMavenPublication(MavenPublication publication, Project
115114
*/
116115
private void addMavenOptionalFeature(Project project) {
117116
JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class);
118-
JavaPluginConvention convention = project.getConvention().getPlugin(JavaPluginConvention.class);
119117
extension.registerFeature("mavenOptional",
120-
(feature) -> feature.usingSourceSet(convention.getSourceSets().getByName("main")));
118+
(feature) -> feature.usingSourceSet(extension.getSourceSets().getByName("main")));
121119
AdhocComponentWithVariants javaComponent = (AdhocComponentWithVariants) project.getComponents()
122120
.findByName("java");
123121
javaComponent.addVariantsFromConfiguration(

buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationPlugin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@
2424
import org.gradle.api.Project;
2525
import org.gradle.api.artifacts.Configuration;
2626
import org.gradle.api.plugins.JavaPlugin;
27-
import org.gradle.api.plugins.JavaPluginConvention;
27+
import org.gradle.api.plugins.JavaPluginExtension;
2828
import org.gradle.api.tasks.SourceSet;
2929

3030
import org.springframework.boot.build.DeployedPlugin;
@@ -66,7 +66,7 @@ public void apply(Project project) {
6666
.add(project.getDependencies().project(Collections.singletonMap("path",
6767
":spring-boot-project:spring-boot-tools:spring-boot-configuration-processor")));
6868
project.getTasks().create("autoConfigurationMetadata", AutoConfigurationMetadata.class, (task) -> {
69-
SourceSet main = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets()
69+
SourceSet main = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
7070
.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
7171
task.setSourceSet(main);
7272
task.dependsOn(main.getClassesTaskName());

buildSrc/src/main/java/org/springframework/boot/build/bom/BomPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import java.util.Set;
2222
import java.util.stream.Collectors;
2323

24+
import groovy.namespace.QName;
2425
import groovy.util.Node;
25-
import groovy.xml.QName;
2626
import org.gradle.api.Plugin;
2727
import org.gradle.api.Project;
2828
import org.gradle.api.artifacts.Configuration;

buildSrc/src/main/java/org/springframework/boot/build/context/properties/ConfigurationPropertiesPlugin.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616

1717
package org.springframework.boot.build.context.properties;
1818

19-
import java.io.File;
2019
import java.util.Collections;
21-
import java.util.concurrent.Callable;
2220
import java.util.stream.Collectors;
2321

2422
import org.gradle.api.Plugin;
@@ -27,7 +25,7 @@
2725
import org.gradle.api.artifacts.Configuration;
2826
import org.gradle.api.file.RegularFile;
2927
import org.gradle.api.plugins.JavaPlugin;
30-
import org.gradle.api.plugins.JavaPluginConvention;
28+
import org.gradle.api.plugins.JavaPluginExtension;
3129
import org.gradle.api.provider.Provider;
3230
import org.gradle.api.tasks.PathSensitivity;
3331
import org.gradle.api.tasks.SourceSet;
@@ -94,20 +92,19 @@ private void addConfigurationProcessorDependency(Project project) {
9492
}
9593

9694
private void disableIncrementalCompilation(Project project) {
97-
SourceSet mainSourceSet = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets()
95+
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
9896
.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
9997
project.getTasks().named(mainSourceSet.getCompileJavaTaskName(), JavaCompile.class)
10098
.configure((compileJava) -> compileJava.getOptions().setIncremental(false));
10199
}
102100

103101
private void addMetadataArtifact(Project project) {
104-
SourceSet mainSourceSet = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets()
102+
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
105103
.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
106104
project.getConfigurations().maybeCreate(CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME);
107105
project.afterEvaluate((evaluatedProject) -> evaluatedProject.getArtifacts().add(
108106
CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME,
109-
evaluatedProject.provider((Callable<File>) () -> new File(mainSourceSet.getJava().getOutputDir(),
110-
"META-INF/spring-configuration-metadata.json")),
107+
mainSourceSet.getJava().getDestinationDirectory().dir("META-INF/spring-configuration-metadata.json"),
111108
(artifact) -> artifact
112109
.builtBy(evaluatedProject.getTasks().getByName(mainSourceSet.getClassesTaskName()))));
113110
}
@@ -117,7 +114,7 @@ private void configureAdditionalMetadataLocationsCompilerArgument(Project projec
117114
.getByName(JavaPlugin.COMPILE_JAVA_TASK_NAME);
118115
((Task) compileJava).getInputs().files(project.getTasks().getByName(JavaPlugin.PROCESS_RESOURCES_TASK_NAME))
119116
.withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("processed resources");
120-
SourceSet mainSourceSet = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets()
117+
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
121118
.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
122119
compileJava.getOptions().getCompilerArgs()
123120
.add("-Aorg.springframework.boot.configurationprocessor.additionalMetadataLocations=" + StringUtils
@@ -130,7 +127,7 @@ private void registerCheckAdditionalMetadataTask(Project project) {
130127
.register(CHECK_ADDITIONAL_SPRING_CONFIGURATION_METADATA_TASK_NAME,
131128
CheckAdditionalSpringConfigurationMetadata.class);
132129
checkConfigurationMetadata.configure((check) -> {
133-
SourceSet mainSourceSet = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets()
130+
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
134131
.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
135132
check.setSource(mainSourceSet.getResources());
136133
check.include("META-INF/additional-spring-configuration-metadata.json");
@@ -145,7 +142,7 @@ private void registerCheckMetadataTask(Project project) {
145142
TaskProvider<CheckSpringConfigurationMetadata> checkConfigurationMetadata = project.getTasks()
146143
.register(CHECK_SPRING_CONFIGURATION_METADATA_TASK_NAME, CheckSpringConfigurationMetadata.class);
147144
checkConfigurationMetadata.configure((check) -> {
148-
SourceSet mainSourceSet = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets()
145+
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
149146
.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
150147
Provider<RegularFile> metadataLocation = project.getTasks()
151148
.named(mainSourceSet.getCompileJavaTaskName(), JavaCompile.class)

buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenExec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class MavenExec extends JavaExec {
4646
public MavenExec() {
4747
setClasspath(mavenConfiguration(getProject()));
4848
args("--batch-mode");
49-
setMain("org.apache.maven.cli.MavenCli");
49+
getMainClass().set("org.apache.maven.cli.MavenCli");
5050
}
5151

5252
public void setProjectDir(File projectDir) {

buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenPluginPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
import org.gradle.api.model.ObjectFactory;
6565
import org.gradle.api.plugins.JavaLibraryPlugin;
6666
import org.gradle.api.plugins.JavaPlugin;
67-
import org.gradle.api.plugins.JavaPluginConvention;
67+
import org.gradle.api.plugins.JavaPluginExtension;
6868
import org.gradle.api.publish.PublishingExtension;
6969
import org.gradle.api.publish.maven.MavenPublication;
7070
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
@@ -225,7 +225,7 @@ private MavenExec addGeneratePluginDescriptorTask(Project project, Jar jarTask,
225225
}
226226

227227
private SourceSet getMainSourceSet(Project project) {
228-
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
228+
SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
229229
return sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
230230
}
231231

buildSrc/src/main/java/org/springframework/boot/build/optional/OptionalDependenciesPlugin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
2020
import org.gradle.api.Project;
2121
import org.gradle.api.artifacts.Configuration;
2222
import org.gradle.api.plugins.JavaPlugin;
23-
import org.gradle.api.plugins.JavaPluginConvention;
23+
import org.gradle.api.plugins.JavaPluginExtension;
2424
import org.gradle.api.tasks.SourceSetContainer;
2525

2626
/**
@@ -44,7 +44,7 @@ public void apply(Project project) {
4444
optional.setCanBeConsumed(false);
4545
optional.setCanBeResolved(false);
4646
project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> {
47-
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class)
47+
SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class)
4848
.getSourceSets();
4949
sourceSets.all((sourceSet) -> {
5050
project.getConfigurations().getByName(sourceSet.getCompileClasspathConfigurationName())

buildSrc/src/main/java/org/springframework/boot/build/test/IntegrationTestPlugin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@
1919
import org.gradle.api.Plugin;
2020
import org.gradle.api.Project;
2121
import org.gradle.api.plugins.JavaPlugin;
22-
import org.gradle.api.plugins.JavaPluginConvention;
22+
import org.gradle.api.plugins.JavaPluginExtension;
2323
import org.gradle.api.tasks.SourceSet;
2424
import org.gradle.api.tasks.SourceSetContainer;
2525
import org.gradle.api.tasks.testing.Test;
@@ -61,7 +61,7 @@ private void configureIntegrationTesting(Project project) {
6161
}
6262

6363
private SourceSet createSourceSet(Project project) {
64-
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
64+
SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
6565
SourceSet intTestSourceSet = sourceSets.create(INT_TEST_SOURCE_SET_NAME);
6666
SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
6767
intTestSourceSet.setCompileClasspath(intTestSourceSet.getCompileClasspath().plus(main.getOutput()));

buildSrc/src/main/java/org/springframework/boot/build/test/SystemTestPlugin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
2020
import org.gradle.api.Project;
2121
import org.gradle.api.Task;
2222
import org.gradle.api.plugins.JavaPlugin;
23-
import org.gradle.api.plugins.JavaPluginConvention;
23+
import org.gradle.api.plugins.JavaPluginExtension;
2424
import org.gradle.api.specs.Spec;
2525
import org.gradle.api.tasks.SourceSet;
2626
import org.gradle.api.tasks.SourceSetContainer;
@@ -65,7 +65,7 @@ private void configureSystemTesting(Project project) {
6565
}
6666

6767
private SourceSet createSourceSet(Project project) {
68-
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
68+
SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
6969
SourceSet systemTestSourceSet = sourceSets.create(SYSTEM_TEST_SOURCE_SET_NAME);
7070
SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
7171
systemTestSourceSet

gradle/wrapper/gradle-wrapper.jar

1.52 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ set -- \
205205
org.gradle.wrapper.GradleWrapperMain \
206206
"$@"
207207

208+
# Stop when "xargs" is not available.
209+
if ! command -v xargs >/dev/null 2>&1
210+
then
211+
die "xargs is not available"
212+
fi
213+
208214
# Use "xargs" to parse quoted args.
209215
#
210216
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

gradlew.bat

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@rem limitations under the License.
1515
@rem
1616

17-
@if "%DEBUG%" == "" @echo off
17+
@if "%DEBUG%"=="" @echo off
1818
@rem ##########################################################################
1919
@rem
2020
@rem Gradle startup script for Windows
@@ -25,7 +25,7 @@
2525
if "%OS%"=="Windows_NT" setlocal
2626

2727
set DIRNAME=%~dp0
28-
if "%DIRNAME%" == "" set DIRNAME=.
28+
if "%DIRNAME%"=="" set DIRNAME=.
2929
set APP_BASE_NAME=%~n0
3030
set APP_HOME=%DIRNAME%
3131

@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
4040

4141
set JAVA_EXE=java.exe
4242
%JAVA_EXE% -version >NUL 2>&1
43-
if "%ERRORLEVEL%" == "0" goto execute
43+
if %ERRORLEVEL% equ 0 goto execute
4444

4545
echo.
4646
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
7575

7676
:end
7777
@rem End local scope for the variables with windows NT shell
78-
if "%ERRORLEVEL%"=="0" goto mainEnd
78+
if %ERRORLEVEL% equ 0 goto mainEnd
7979

8080
:fail
8181
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
8282
rem the _cmd.exe /c_ return code!
83-
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84-
exit /b 1
83+
set EXIT_CODE=%ERRORLEVEL%
84+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
85+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
86+
exit /b %EXIT_CODE%
8587

8688
:mainEnd
8789
if "%OS%"=="Windows_NT" endlocal

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ThreadDumpEndpointDocumentationTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -187,7 +187,10 @@ void textThreadDump() throws Exception {
187187
.andDo(MockMvcRestDocumentation.document("threaddump/text",
188188
preprocessResponse(new ContentModifyingOperationPreprocessor((bytes, mediaType) -> {
189189
String content = new String(bytes, StandardCharsets.UTF_8);
190-
return content.substring(0, content.indexOf("\"main\" - Thread")).getBytes();
190+
int mainThreadIndex = content.indexOf("\"main\" - Thread");
191+
String truncatedContent = (mainThreadIndex >= 0) ? content.substring(0, mainThreadIndex)
192+
: content;
193+
return truncatedContent.getBytes();
191194
}))));
192195
}
193196

spring-boot-project/spring-boot-parent/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,9 @@ bom {
205205

206206
dependencies {
207207
api(enforcedPlatform(project(":spring-boot-project:spring-boot-dependencies")))
208-
}
208+
}
209+
210+
tasks.withType(GenerateModuleMetadata).configureEach {
211+
// Internal module so enforced platform dependencies are OK
212+
suppressedValidationErrors.add('enforced-platform')
213+
}

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/dsl/SpringBootExtension.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,9 +22,9 @@
2222
import org.gradle.api.Project;
2323
import org.gradle.api.plugins.BasePlugin;
2424
import org.gradle.api.plugins.JavaPlugin;
25-
import org.gradle.api.plugins.JavaPluginConvention;
2625
import org.gradle.api.provider.Property;
2726
import org.gradle.api.tasks.SourceSet;
27+
import org.gradle.api.tasks.SourceSetContainer;
2828
import org.gradle.api.tasks.TaskContainer;
2929
import org.gradle.api.tasks.TaskProvider;
3030
import org.gradle.jvm.tasks.Jar;
@@ -112,8 +112,12 @@ private void configureBuildInfoTask(BuildInfo task) {
112112
}
113113

114114
private File determineMainSourceSetResourcesOutputDir() {
115-
return this.project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets()
116-
.getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput().getResourcesDir();
115+
return sourceSets(this.project).getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput().getResourcesDir();
116+
}
117+
118+
@SuppressWarnings("deprecation")
119+
private SourceSetContainer sourceSets(Project project) {
120+
return project.getConvention().getPlugin(org.gradle.api.plugins.JavaPluginConvention.class).getSourceSets();
117121
}
118122

119123
private String determineArtifactBaseName() {

0 commit comments

Comments
 (0)