From aa5acf8c17c288ae4ea5e2ac559917d335857aa2 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sun, 16 Aug 2026 17:55:28 -0700 Subject: [PATCH] build: fix build on Gradle 9.5+ and restore publishing on 9.6+ Bumping the wrapper past 9.4.1 (#3016) surfaced two independent regressions. 1. Gradle 9.5.0 broke `testlib/build.gradle`: Could not get unknown property 'sourceSets' for project ':lib' of type ...DefaultProjectDependency Inside a `dependencies { }` block, `project(path)` used to resolve to `Project.project(String)` and return a `Project`. As of 9.5.0 it resolves to `DependencyHandler.project(String)` and returns a `ProjectDependency`, which has no `sourceSets`: 9.4.1: project(String) -> ...project.LifecycleAwareProject_Decorated 9.5.0: project(String) -> ...dependencies.DefaultProjectDependency_Decorated The line turns out to be unnecessary. `:lib`'s jar already bundles every glue source set, and that jar is on testlib's runtime classpath, which is where FeatureClassLoader resolves `com.diffplug.spotless.glue.*`. So just drop it. 2. Gradle 9.6.0 silently broke publishing. The legacy software-model `model { publishing { } }` rule no longer binds, so the pluginMaven publication is never created and publishToMavenLocal becomes a no-op with no error: 9.5.1: > Task :lib-extra:publishPluginMavenPublicationToMavenLocal 9.6.0: > Task :lib-extra:publishToMavenLocal UP-TO-DATE Unwrapping it to a plain `publishing { }` block fixes it. The software model is slated for removal in Gradle 10 anyway. Generated pom-default.xml and module.json are byte-identical before and after for all four published projects. Neither change is documented in Gradle's 9.5/9.6 release notes or the 9.x upgrade guide. Verified at 9.7.0: spotlessCheck, `assemble testClasses`, and `build -x spotlessCheck -PSPOTLESS_EXCLUDE_MAVEN=true` (748 tests) all pass, publishToMavenLocal runs the same 66 tasks as on 9.4.1, and the signing/Sonatype release tasks are still wired. Everything still passes on 9.4.1, so this can land ahead of the wrapper bump. Co-Authored-By: Claude Opus 5 (1M context) --- gradle/java-publish.gradle | 124 ++++++++++++++++++------------------- testlib/build.gradle | 1 - 2 files changed, 61 insertions(+), 64 deletions(-) diff --git a/gradle/java-publish.gradle b/gradle/java-publish.gradle index 80931905ef..d9f4932141 100644 --- a/gradle/java-publish.gradle +++ b/gradle/java-publish.gradle @@ -95,77 +95,75 @@ final MAVEN_PLUGIN_ARTIFACT_NAME = 'spotless-maven-plugin' boolean isExt = project.name.startsWith('eclipse-') boolean isPluginMaven = project.ext.artifactId == 'spotless-maven-plugin' -model { - publishing { - publications { - pluginMaven(MavenPublication) { - if (project.ext.artifactId != 'spotless-plugin-gradle') { - from components.java - } +publishing { + publications { + pluginMaven(MavenPublication) { + if (project.ext.artifactId != 'spotless-plugin-gradle') { + from components.java + } - groupId = project.group - artifactId = project.ext.artifactId - version = project.version - - def projectExtArtifactId = project.ext.artifactId - def projectDescription = project.description - def projectOrg = project.org - def rootProjectName = rootProject.name - - pom.withXml { - // add MavenCentral requirements to the POM - asNode().children().last() + { - resolveStrategy = Closure.DELEGATE_FIRST - name projectExtArtifactId - description projectDescription + groupId = project.group + artifactId = project.ext.artifactId + version = project.version + + def projectExtArtifactId = project.ext.artifactId + def projectDescription = project.description + def projectOrg = project.org + def rootProjectName = rootProject.name + + pom.withXml { + // add MavenCentral requirements to the POM + asNode().children().last() + { + resolveStrategy = Closure.DELEGATE_FIRST + name projectExtArtifactId + description projectDescription + url "https://github.com/${projectOrg}/${rootProjectName}" + scm { url "https://github.com/${projectOrg}/${rootProjectName}" - scm { - url "https://github.com/${projectOrg}/${rootProjectName}" - connection "scm:git:https://github.com/${projectOrg}/${rootProjectName}.git" - developerConnection "scm:git:ssh:git@github.com/${projectOrg}/${rootProjectName}.git" - } - licenses { - if (isExt) { - license { - name 'Eclipse Public License - v 1.0' - url 'https://www.eclipse.org/legal/epl-v10.html' - distribution 'repo' - } - } else { - license { - name 'The Apache Software License, Version 2.0' - url 'https://www.apache.org/licenses/LICENSE-2.0.txt' - distribution 'repo' - } + connection "scm:git:https://github.com/${projectOrg}/${rootProjectName}.git" + developerConnection "scm:git:ssh:git@github.com/${projectOrg}/${rootProjectName}.git" + } + licenses { + if (isExt) { + license { + name 'Eclipse Public License - v 1.0' + url 'https://www.eclipse.org/legal/epl-v10.html' + distribution 'repo' + } + } else { + license { + name 'The Apache Software License, Version 2.0' + url 'https://www.apache.org/licenses/LICENSE-2.0.txt' + distribution 'repo' } } - if (isPluginMaven) { - // Maven plugin required Maven 3.1.0+ to run - prerequisites { maven '3.1.0' } - } - developers { - if (isExt) { - project.ext.developers.each { extId, extValues -> - developer { - id extId - name extValues['name'] - email extValues['email'] - } - } - } else { - if (isPluginMaven) { - developer { - id 'lutovich' - name 'Konstantin Lutovich' - email 'konstantin.lutovich@neotechnology.com' - } + } + if (isPluginMaven) { + // Maven plugin required Maven 3.1.0+ to run + prerequisites { maven '3.1.0' } + } + developers { + if (isExt) { + project.ext.developers.each { extId, extValues -> + developer { + id extId + name extValues['name'] + email extValues['email'] } + } + } else { + if (isPluginMaven) { developer { - id 'nedtwigg' - name 'Ned Twigg' - email 'ned.twigg@diffplug.com' + id 'lutovich' + name 'Konstantin Lutovich' + email 'konstantin.lutovich@neotechnology.com' } } + developer { + id 'nedtwigg' + name 'Ned Twigg' + email 'ned.twigg@diffplug.com' + } } } } diff --git a/testlib/build.gradle b/testlib/build.gradle index 3ba4f011a5..3cc5fdc3fa 100644 --- a/testlib/build.gradle +++ b/testlib/build.gradle @@ -7,7 +7,6 @@ apply from: rootProject.file('gradle/java-setup.gradle') dependencies { api projects.lib - api files(project(projects.lib.path).sourceSets.sortPom.output.classesDirs) api libs.durian.core api libs.durian.testlib api libs.junit.jupiter