From 641d8a362b551bd595e434b87effb858096fa9ed Mon Sep 17 00:00:00 2001 From: Pavel Vassiliev Date: Sat, 10 Jan 2026 22:19:11 -0500 Subject: [PATCH] Fix Gradle 9.0 deprecations This commit addresses several build warnings and errors to prepare for Gradle 9.0 and resolve static analysis issues. Closes: gh-18472 Signed-off-by: Pavel Vassiliev Signed-off-by: Pavel Vassiliev --- aspects/spring-security-aspects.gradle | 8 ++++---- build.gradle | 20 +++++++++---------- buildSrc/build.gradle | 2 +- .../gradle/convention/DocsPlugin.groovy | 4 ++-- .../convention/IntegrationTestPlugin.groovy | 4 ++-- .../gradle/convention/JavadocApiPlugin.groovy | 6 +++--- .../gradle/convention/SchemaZipPlugin.groovy | 2 +- config/spring-security-config.gradle | 4 ++-- gradle/libs.versions.toml | 4 ++-- settings.gradle | 2 +- 10 files changed, 27 insertions(+), 29 deletions(-) diff --git a/aspects/spring-security-aspects.gradle b/aspects/spring-security-aspects.gradle index 9df4e61538..bc0fd41d6d 100644 --- a/aspects/spring-security-aspects.gradle +++ b/aspects/spring-security-aspects.gradle @@ -2,12 +2,12 @@ apply plugin: 'io.spring.convention.spring-module' apply plugin: 'io.freefair.aspectj' compileAspectj { - sourceCompatibility "17" - targetCompatibility "17" + sourceCompatibility = "17" + targetCompatibility = "17" } compileTestAspectj { - sourceCompatibility "17" - targetCompatibility "17" + sourceCompatibility = "17" + targetCompatibility = "17" } dependencies { diff --git a/build.gradle b/build.gradle index 1f64875227..33a1ae068e 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { classpath libs.com.netflix.nebula.nebula.project.plugin } repositories { - maven { url 'https://plugins.gradle.org/m2/' } + maven { url='https://plugins.gradle.org/m2/' } } } @@ -35,7 +35,7 @@ ext.milestoneBuild = !(snapshotBuild || releaseBuild) repositories { mavenCentral() - maven { url "https://repo.spring.io/milestone" } + maven { url = "https://repo.spring.io/milestone" } } springRelease { @@ -76,16 +76,14 @@ allprojects { apply plugin: 'io.spring.javaformat' apply plugin: 'checkstyle' - pluginManager.withPlugin("io.spring.convention.checkstyle", { plugin -> - configure(plugin) { - dependencies { - checkstyle libs.io.spring.javaformat.spring.javaformat.checkstyle - } - checkstyle { - toolVersion = '8.34' - } + pluginManager.withPlugin("io.spring.convention.checkstyle") { + dependencies { + checkstyle libs.io.spring.javaformat.spring.javaformat.checkstyle } - }) + checkstyle { + toolVersion = '8.34' + } + } if (project.name.contains('sample')) { tasks.whenTaskAdded { task -> diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 87b5fcd62f..da60b4197b 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -12,7 +12,7 @@ java { repositories { gradlePluginPortal() mavenCentral() - maven { url 'https://repo.spring.io/snapshot' } + maven { url = 'https://repo.spring.io/snapshot' } } sourceSets { diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy index 318fb24f73..9da53433c4 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy @@ -31,12 +31,12 @@ public class DocsPlugin implements Plugin { into 'api' } into 'docs' - duplicatesStrategy 'exclude' + duplicatesStrategy = 'exclude' } Task docs = project.tasks.create("docs") { group = 'Documentation' - description 'An aggregator task to generate all the documentation' + description = 'An aggregator task to generate all the documentation' dependsOn docsZip } project.tasks.assemble.dependsOn docs diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy index 6681d745f0..bfd86838c9 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy @@ -90,7 +90,7 @@ public class IntegrationTestPlugin implements Plugin { project.plugins.withType(IdeaPlugin) { project.idea { module { - testSourceDirs += project.file('src/integration-test/java') + testSources.from(project.file('src/integration-test/java')) scopes.TEST.plus += [ project.configurations.integrationTestCompileClasspath ] } } @@ -105,7 +105,7 @@ public class IntegrationTestPlugin implements Plugin { project.plugins.withType(IdeaPlugin) { project.idea { module { - testSourceDirs += project.file('src/integration-test/groovy') + testSources.from(project.file('src/integration-test/groovy')) } } } diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/JavadocApiPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/JavadocApiPlugin.groovy index afb99a4ee6..80fc560202 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/JavadocApiPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/JavadocApiPlugin.groovy @@ -26,7 +26,7 @@ import org.gradle.api.Action; import org.gradle.api.JavaVersion import org.gradle.api.Plugin; import org.gradle.api.Project; -import org.gradle.api.plugins.JavaPluginConvention; +import org.gradle.api.plugins.JavaPluginExtension; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.javadoc.Javadoc; import org.slf4j.Logger; @@ -71,7 +71,7 @@ public class JavadocApiPlugin implements Plugin { } api.setMaxMemory("1024m"); - api.setDestinationDir(new File(project.getBuildDir(), "api")); + api.setDestinationDir(project.layout.getBuildDirectory().dir("api").get().getAsFile()); project.getPluginManager().apply("io.spring.convention.javadoc-options"); } @@ -99,7 +99,7 @@ public class JavadocApiPlugin implements Plugin { public void execute(SpringModulePlugin plugin) { logger.info("Added sources for {}", project); - JavaPluginConvention java = project.getConvention().getPlugin(JavaPluginConvention.class); + JavaPluginExtension java = project.getExtensions().getByType(JavaPluginExtension.class); SourceSet mainSourceSet = java.getSourceSets().getByName("main"); api.setSource(api.getSource().plus(mainSourceSet.getAllJava())); diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaZipPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaZipPlugin.groovy index cb1fb3b8a4..d7ba54d8eb 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaZipPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaZipPlugin.groovy @@ -40,7 +40,7 @@ public class SchemaZipPlugin implements Plugin { throw new IllegalStateException("Could not find schema file for resource name " + schemaResourceName + " in src/main/resources") } schemaZip.into (shortName) { - duplicatesStrategy 'exclude' + duplicatesStrategy = 'exclude' from xsdFile.path } versionlessXsd.getInputFiles().from(xsdFile.path) diff --git a/config/spring-security-config.gradle b/config/spring-security-config.gradle index 70acef94c0..d732cf4c2d 100644 --- a/config/spring-security-config.gradle +++ b/config/spring-security-config.gradle @@ -144,14 +144,14 @@ tasks.named('processResources', ProcessResources).configure { into 'org/springframework/security/config/' } from(rncToXsd) { - duplicatesStrategy DuplicatesStrategy.EXCLUDE + duplicatesStrategy = DuplicatesStrategy.EXCLUDE into 'org/springframework/security/config/' } } tasks.named('sourcesJar', Jar).configure { from(rncToXsd) { - duplicatesStrategy DuplicatesStrategy.EXCLUDE + duplicatesStrategy = DuplicatesStrategy.EXCLUDE into 'org/springframework/security/config/' } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f07284a8b1..d4cc52f66a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -92,12 +92,12 @@ com-thaiopensource-trag = "com.thaiopensource:trang:20091111" net-sourceforge-saxon-saxon = "net.sourceforge.saxon:saxon:9.1.0.8" org-yaml-snakeyaml = "org.yaml:snakeyaml:1.33" org-apache-commons-commons-io = "org.apache.commons:commons-io:1.3.2" -io-github-gradle-nexus-publish-plugin = "io.github.gradle-nexus:publish-plugin:1.3.0" +io-github-gradle-nexus-publish-plugin = "io.github.gradle-nexus:publish-plugin:2.0.0" org-gretty-gretty = "org.gretty:gretty:4.1.10" com-github-ben-manes-gradle-versions-plugin = "com.github.ben-manes:gradle-versions-plugin:0.52.0" com-github-spullara-mustache-java-compiler = "com.github.spullara.mustache.java:compiler:0.9.14" org-hidetake-gradle-ssh-plugin = "org.hidetake:gradle-ssh-plugin:2.10.1" -org-jfrog-buildinfo-build-info-extractor-gradle = "org.jfrog.buildinfo:build-info-extractor-gradle:4.34.2" +org-jfrog-buildinfo-build-info-extractor-gradle = "org.jfrog.buildinfo:build-info-extractor-gradle:6.0.4" org-sonarsource-scanner-gradle-sonarqube-gradle-plugin = "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.8.0.1969" org-instancio-instancio-junit = "org.instancio:instancio-junit:3.7.1" diff --git a/settings.gradle b/settings.gradle index ded5ff1503..42bd2c9684 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,7 +11,7 @@ plugins { dependencyResolutionManagement { repositories { mavenCentral() - maven { url "https://repo.spring.io/snapshot" } + maven { url = "https://repo.spring.io/snapshot" } } }