Fix build on Gradle 9.5+ and restore publishing on 9.6+ - #3019
Merged
Conversation
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) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unblocks #3016 (Gradle
9.4.1→9.7.0). Bisecting that PR's failure turned up two independent regressions, not one — and fixing only the first would have converted a loud failure into a silent one.Could not get unknown property 'sourceSets' for project ':lib'— hard failuretestlib/build.gradlepublishToMavenLocalsilently becomes a no-op — no error at allgradle/java-publish.gradle1. Gradle 9.5.0 —
project(path).sourceSetsInside a
dependencies { }block,project(path)used to resolve toProject.project(String)and return aProject. As of 9.5.0 it resolves toDependencyHandler.project(String)and returns aProjectDependency, which has nosourceSets. Same expression, same script:The line turns out to be unnecessary.
:lib's jar already bundles every glue source set (jar { from sourceSets.getByName(glue).output.classesDirs }), and that jar is on testlib's runtime classpath — which is whereFeatureClassLoaderresolvescom.diffplug.spotless.glue.*. So it's simply dropped.2. Gradle 9.6.0 — publishing silently stops
Publishing was wrapped in the legacy software-model
model { publishing { … } }block. In 9.6.0 that rule no longer binds, so thepluginMavenpublication is never created:Unwrapping to a plain
publishing { }fixes it. Ignoring whitespace the diff is exactly two deleted lines. The software model is slated for removal in Gradle 10 regardless, so this was owed anyway.Neither change is mentioned in Gradle's 9.5/9.6 release notes or the 9.x upgrade guide. Both look worth reporting upstream, especially the silent one.
Verification at 9.7.0
./gradlew spotlessCheck— the job that failed on chore(deps): update gradle to v9.7.0 #3016 — passes./gradlew assemble testClassespasses./gradlew build -x spotlessCheck -PSPOTLESS_EXCLUDE_MAVEN=true(CI's main job) — 748 tests, 0 failurespublishToMavenLocalruns the same 66 tasks as on 9.4.1pom-default.xml+module.jsonare byte-identical before/after for all 4 published projectssignPluginMavenPublicationandpublishPluginMavenPublicationToSonatypeRepository(whichchangelogBumpdepends on) still exist under-Prelease=trueEverything still passes on 9.4.1, so this lands safely ahead of the wrapper bump — #3016 should go green on rebase without changes of its own.
No
CHANGES.mdentry: build infrastructure only, nothing user-facing.🤖 Generated with Claude Code