Skip to content

Commit eafe61c

Browse files
committed
Backport upgrade to Gradle 8.10.1
Cherry-pick commits d756bf4, 083ac67 and 162c929 to upgrade to Gradle 8.10.1. Closes gh-42433
1 parent 23ddad1 commit eafe61c

File tree

23 files changed

+129
-104
lines changed

23 files changed

+129
-104
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ jobs:
2222
- version: 17
2323
toolchain: false
2424
- version: 21
25-
toolchain: true
25+
toolchain: false
2626
- version: 22
27-
toolchain: true
27+
toolchain: false
2828
- version: 23
2929
toolchain: true
3030
exclude:

buildSrc/build.gradle

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ repositories {
1010
gradlePluginPortal()
1111
}
1212

13-
sourceCompatibility = 17
14-
targetCompatibility = 17
13+
java {
14+
sourceCompatibility = 17
15+
targetCompatibility = 17
16+
}
17+
1518

1619
if ("${springFrameworkVersion}".contains("-")) {
1720
repositories {
@@ -34,6 +37,7 @@ dependencies {
3437
implementation("com.tngtech.archunit:archunit:1.3.0")
3538
implementation("commons-codec:commons-codec:${commonsCodecVersion}")
3639
implementation("de.undercouch.download:de.undercouch.download.gradle.plugin:5.5.0")
40+
implementation("dev.adamko.dokkatoo:dokkatoo-plugin:2.3.1")
3741
implementation("io.spring.javaformat:spring-javaformat-gradle-plugin:${javaFormatVersion}")
3842
implementation("org.apache.maven:maven-embedder:${mavenVersion}")
3943
implementation("org.asciidoctor:asciidoctor-gradle-jvm:4.0.2")

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

+31-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616

1717
package org.springframework.boot.build;
1818

19+
import java.net.URI;
1920
import java.util.ArrayList;
2021
import java.util.List;
2122

23+
import dev.adamko.dokkatoo.DokkatooExtension;
24+
import dev.adamko.dokkatoo.formats.DokkatooHtmlPlugin;
2225
import org.gradle.api.Project;
26+
import org.gradle.api.tasks.SourceSet;
27+
import org.gradle.api.tasks.SourceSetContainer;
2328
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions;
2429
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile;
2530

@@ -44,9 +49,10 @@
4449
class KotlinConventions {
4550

4651
void apply(Project project) {
47-
project.getPlugins()
48-
.withId("org.jetbrains.kotlin.jvm",
49-
(plugin) -> project.getTasks().withType(KotlinCompile.class, this::configure));
52+
project.getPlugins().withId("org.jetbrains.kotlin.jvm", (plugin) -> {
53+
project.getTasks().withType(KotlinCompile.class, this::configure);
54+
project.getPlugins().withType(DokkatooHtmlPlugin.class, (dokkatooPlugin) -> configureDokkatoo(project));
55+
});
5056
}
5157

5258
private void configure(KotlinCompile compile) {
@@ -60,4 +66,26 @@ private void configure(KotlinCompile compile) {
6066
compile.getKotlinOptions().setFreeCompilerArgs(freeCompilerArgs);
6167
}
6268

69+
private void configureDokkatoo(Project project) {
70+
DokkatooExtension dokkatoo = project.getExtensions().getByType(DokkatooExtension.class);
71+
dokkatoo.getDokkatooSourceSets().named(SourceSet.MAIN_SOURCE_SET_NAME).configure((sourceSet) -> {
72+
sourceSet.getSourceRoots().setFrom(project.file("src/main/kotlin"));
73+
sourceSet.getClasspath()
74+
.from(project.getExtensions()
75+
.getByType(SourceSetContainer.class)
76+
.getByName(SourceSet.MAIN_SOURCE_SET_NAME)
77+
.getOutput());
78+
sourceSet.getExternalDocumentationLinks().create("spring-boot-javadoc", (link) -> {
79+
link.getUrl().set(URI.create("https://docs.spring.io/spring-boot/api/java/"));
80+
link.getPackageListUrl().set(URI.create("https://docs.spring.io/spring-boot/api/java/element-list"));
81+
});
82+
sourceSet.getExternalDocumentationLinks().create("spring-framework-javadoc", (link) -> {
83+
String url = "https://docs.spring.io/spring-framework/docs/%s/javadoc-api/"
84+
.formatted(project.property("springFrameworkVersion"));
85+
link.getUrl().set(URI.create(url));
86+
link.getPackageListUrl().set(URI.create(url + "/element-list"));
87+
});
88+
});
89+
}
90+
6391
}

buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/InteractiveUpgradeResolver.java

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 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.
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.boot.build.bom.bomr;
1818

19+
import java.util.ArrayList;
1920
import java.util.Collection;
2021
import java.util.HashMap;
2122
import java.util.List;
@@ -58,12 +59,17 @@ private Upgrade resolveUpgrade(LibraryWithVersionOptions libraryWithVersionOptio
5859
if (libraryWithVersionOptions.getVersionOptions().isEmpty()) {
5960
return null;
6061
}
61-
VersionOption current = new VersionOption(libraryWithVersionOptions.getLibrary().getVersion().getVersion());
62-
VersionOption selected = this.userInputHandler.selectOption(
63-
libraryWithVersionOptions.getLibrary().getName() + " "
64-
+ libraryWithVersionOptions.getLibrary().getVersion().getVersion(),
65-
libraryWithVersionOptions.getVersionOptions(), current);
66-
return (selected.equals(current)) ? null
62+
VersionOption defaultOption = new VersionOption(
63+
libraryWithVersionOptions.getLibrary().getVersion().getVersion());
64+
VersionOption selected = this.userInputHandler.askUser((questions) -> {
65+
String question = libraryWithVersionOptions.getLibrary().getName() + " "
66+
+ libraryWithVersionOptions.getLibrary().getVersion().getVersion();
67+
List<VersionOption> options = new ArrayList<>();
68+
options.add(defaultOption);
69+
options.addAll(libraryWithVersionOptions.getVersionOptions());
70+
return questions.selectOption(question, options, defaultOption);
71+
}).get();
72+
return (selected.equals(defaultOption)) ? null
6773
: new Upgrade(libraryWithVersionOptions.getLibrary(), selected.getVersion());
6874
}
6975

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

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ private void configureDockerTesting(Project project) {
7171
.add(project.getConfigurations()
7272
.getByName(dockerTestSourceSet.getRuntimeClasspathConfigurationName())));
7373
});
74+
project.getDependencies()
75+
.add(dockerTestSourceSet.getRuntimeOnlyConfigurationName(), "org.junit.platform:junit-platform-launcher");
7476
}
7577

7678
private SourceSet createSourceSet(Project project) {

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 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.
@@ -58,6 +58,8 @@ private void configureIntegrationTesting(Project project) {
5858
eclipse.classpath((classpath) -> classpath.getPlusConfigurations()
5959
.add(project.getConfigurations().getByName(intTestSourceSet.getRuntimeClasspathConfigurationName())));
6060
});
61+
project.getDependencies()
62+
.add(intTestSourceSet.getRuntimeOnlyConfigurationName(), "org.junit.platform:junit-platform-launcher");
6163
}
6264

6365
private SourceSet createSourceSet(Project project) {

gradle/wrapper/gradle-wrapper.jar

121 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,8 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90+
' "$PWD" ) || exit
8891

8992
# Use the maximum available, or set MAX_FD != -1 to use that value.
9093
MAX_FD=maximum

gradlew.bat

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################

spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ tasks.named("test") {
235235
}
236236

237237
def documentationTest = tasks.register("documentationTest", Test) {
238+
testClassesDirs = testing.suites.test.sources.output.classesDirs
239+
classpath = testing.suites.test.sources.runtimeClasspath
238240
filter {
239241
includeTestsMatching("org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.*")
240242
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
id "dev.adamko.dokkatoo-html"
23
id "java"
34
id "org.asciidoctor.jvm.convert"
45
id "org.springframework.boot.conventions"
@@ -47,7 +48,7 @@ sourcesJar {
4748
}
4849

4950
plugins.withType(EclipsePlugin) {
50-
extensions.getByType(org.gradle.plugins.ide.eclipse.model.EclipseModel).classpath { classpath ->
51+
eclipse.classpath { classpath ->
5152
classpath.plusConfigurations.add(configurations.getByName(sourceSets.main.runtimeClasspathConfigurationName))
5253
}
5354
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
id "dev.adamko.dokkatoo-html"
23
id "java-library"
34
id "org.jetbrains.kotlin.jvm"
45
id "org.springframework.boot.conventions"

spring-boot-project/spring-boot-tools/spring-boot-cli/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ def configureArchive(archive) {
8282
into "lib/"
8383
}
8484
archive.from(file("src/main/content")) {
85-
dirMode = 0755
86-
fileMode = 0644
85+
dirPermissions { unix(0755) }
86+
filePermissions { unix(0644) }
8787
}
8888
archive.from(file("src/main/executablecontent")) {
89-
fileMode = 0755
89+
filePermissions { unix(0755) }
9090
}
9191
}
9292

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

+7-25
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919
import java.io.IOException;
2020
import java.io.InputStreamReader;
2121
import java.io.StringWriter;
22-
import java.lang.reflect.Method;
2322
import java.util.concurrent.Callable;
2423

25-
import org.gradle.api.Action;
2624
import org.gradle.api.GradleException;
2725
import org.gradle.api.Plugin;
2826
import org.gradle.api.Project;
@@ -128,32 +126,16 @@ private String loadResource(String name) {
128126

129127
private void configureFilePermissions(CopySpec copySpec, int mode) {
130128
if (GradleVersion.current().compareTo(GradleVersion.version("8.3")) >= 0) {
131-
try {
132-
Method filePermissions = copySpec.getClass().getMethod("filePermissions", Action.class);
133-
filePermissions.invoke(copySpec, new Action<Object>() {
134-
135-
@Override
136-
public void execute(Object filePermissions) {
137-
String unixPermissions = Integer.toString(mode, 8);
138-
try {
139-
Method unix = filePermissions.getClass().getMethod("unix", String.class);
140-
unix.invoke(filePermissions, unixPermissions);
141-
}
142-
catch (Exception ex) {
143-
throw new GradleException("Failed to set file permissions to '" + unixPermissions + "'",
144-
ex);
145-
}
146-
}
147-
148-
});
149-
}
150-
catch (Exception ex) {
151-
throw new GradleException("Failed to set file permissions", ex);
152-
}
129+
copySpec.filePermissions((filePermissions) -> filePermissions.unix(Integer.toString(mode, 8)));
153130
}
154131
else {
155-
copySpec.setFileMode(mode);
132+
configureFileMode(copySpec, mode);
156133
}
157134
}
158135

136+
@SuppressWarnings("deprecation")
137+
private void configureFileMode(CopySpec copySpec, int mode) {
138+
copySpec.setFileMode(mode);
139+
}
140+
159141
}

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootArchiveSupport.java

+24-25
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626
import java.util.Set;
2727
import java.util.TreeMap;
2828
import java.util.function.Function;
29-
import java.util.function.Supplier;
3029

31-
import org.gradle.api.GradleException;
30+
import org.gradle.api.file.ConfigurableFilePermissions;
3231
import org.gradle.api.file.CopySpec;
3332
import org.gradle.api.file.FileCopyDetails;
3433
import org.gradle.api.file.FileTreeElement;
@@ -133,44 +132,44 @@ CopyAction createCopyAction(Jar jar, ResolvedDependencies resolvedDependencies,
133132
File output = jar.getArchiveFile().get().getAsFile();
134133
Manifest manifest = jar.getManifest();
135134
boolean preserveFileTimestamps = jar.isPreserveFileTimestamps();
136-
Integer dirMode = getDirMode(jar);
137-
Integer fileMode = getFileMode(jar);
135+
Integer dirPermissions = getUnixNumericDirPermissions(jar);
136+
Integer filePermissions = getUnixNumericFilePermissions(jar);
138137
boolean includeDefaultLoader = isUsingDefaultLoader(jar);
139138
Spec<FileTreeElement> requiresUnpack = this.requiresUnpack.getAsSpec();
140139
Spec<FileTreeElement> exclusions = this.exclusions.getAsExcludeSpec();
141140
LaunchScriptConfiguration launchScript = this.launchScript;
142141
Spec<FileCopyDetails> librarySpec = this.librarySpec;
143142
Function<FileCopyDetails, ZipCompression> compressionResolver = this.compressionResolver;
144143
String encoding = jar.getMetadataCharset();
145-
CopyAction action = new BootZipCopyAction(output, manifest, preserveFileTimestamps, dirMode, fileMode,
146-
includeDefaultLoader, layerToolsLocation, requiresUnpack, exclusions, launchScript, librarySpec,
147-
compressionResolver, encoding, resolvedDependencies, supportsSignatureFile, layerResolver,
144+
CopyAction action = new BootZipCopyAction(output, manifest, preserveFileTimestamps, dirPermissions,
145+
filePermissions, includeDefaultLoader, layerToolsLocation, requiresUnpack, exclusions, launchScript,
146+
librarySpec, compressionResolver, encoding, resolvedDependencies, supportsSignatureFile, layerResolver,
148147
loaderImplementation);
149148
return jar.isReproducibleFileOrder() ? new ReproducibleOrderingCopyAction(action) : action;
150149
}
151150

152-
private Integer getDirMode(CopySpec copySpec) {
153-
return getMode(copySpec, "getDirPermissions", () -> copySpec.getDirMode());
151+
private Integer getUnixNumericDirPermissions(CopySpec copySpec) {
152+
return (GradleVersion.current().compareTo(GradleVersion.version("8.3")) >= 0)
153+
? asUnixNumeric(copySpec.getDirPermissions()) : getDirMode(copySpec);
154154
}
155155

156-
private Integer getFileMode(CopySpec copySpec) {
157-
return getMode(copySpec, "getFilePermissions", () -> copySpec.getFileMode());
156+
private Integer getUnixNumericFilePermissions(CopySpec copySpec) {
157+
return (GradleVersion.current().compareTo(GradleVersion.version("8.3")) >= 0)
158+
? asUnixNumeric(copySpec.getFilePermissions()) : getFileMode(copySpec);
158159
}
159160

160-
@SuppressWarnings("unchecked")
161-
private Integer getMode(CopySpec copySpec, String methodName, Supplier<Integer> fallback) {
162-
if (GradleVersion.current().compareTo(GradleVersion.version("8.3")) >= 0) {
163-
try {
164-
Object filePermissions = ((Property<Object>) copySpec.getClass().getMethod(methodName).invoke(copySpec))
165-
.getOrNull();
166-
return (filePermissions != null)
167-
? (int) filePermissions.getClass().getMethod("toUnixNumeric").invoke(filePermissions) : null;
168-
}
169-
catch (Exception ex) {
170-
throw new GradleException("Failed to get permissions", ex);
171-
}
172-
}
173-
return fallback.get();
161+
private Integer asUnixNumeric(Property<ConfigurableFilePermissions> permissions) {
162+
return permissions.isPresent() ? permissions.get().toUnixNumeric() : null;
163+
}
164+
165+
@SuppressWarnings("deprecation")
166+
private Integer getDirMode(CopySpec copySpec) {
167+
return copySpec.getDirMode();
168+
}
169+
170+
@SuppressWarnings("deprecation")
171+
private Integer getFileMode(CopySpec copySpec) {
172+
return copySpec.getFileMode();
174173
}
175174

176175
private boolean isUsingDefaultLoader(Jar jar) {

0 commit comments

Comments
 (0)