Skip to content

Fix build on Gradle 9.5+ and restore publishing on 9.6+ - #3019

Merged
nedtwigg merged 1 commit into
mainfrom
fix/gradle-9.5-9.6-build-breakage
Aug 17, 2026
Merged

Fix build on Gradle 9.5+ and restore publishing on 9.6+#3019
nedtwigg merged 1 commit into
mainfrom
fix/gradle-9.5-9.6-build-breakage

Conversation

@nedtwigg

Copy link
Copy Markdown
Member

Unblocks #3016 (Gradle 9.4.19.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.

Breaks in Symptom File
9.5.0 Could not get unknown property 'sourceSets' for project ':lib' — hard failure testlib/build.gradle
9.6.0 publishToMavenLocal silently becomes a no-op — no error at all gradle/java-publish.gradle

1. Gradle 9.5.0 — project(path).sourceSets

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. Same expression, same script:

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 (jar { from sourceSets.getByName(glue).output.classesDirs }), and that jar is on testlib's runtime classpath — which is where FeatureClassLoader resolves com.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 the pluginMaven publication is never created:

9.5.1: > Task :lib-extra:publishPluginMavenPublicationToMavenLocal   (13 tasks executed)
9.6.0: > Task :lib-extra:publishToMavenLocal UP-TO-DATE              (nothing)

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 testClasses passes
  • ./gradlew build -x spotlessCheck -PSPOTLESS_EXCLUDE_MAVEN=true (CI's main job) — 748 tests, 0 failures
  • publishToMavenLocal runs the same 66 tasks as on 9.4.1
  • Generated pom-default.xml + module.json are byte-identical before/after for all 4 published projects
  • signPluginMavenPublication and publishPluginMavenPublicationToSonatypeRepository (which changelogBump depends on) still exist under -Prelease=true

Everything 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.md entry: build infrastructure only, nothing user-facing.

🤖 Generated with Claude Code

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>
@nedtwigg
nedtwigg merged commit 9556ad4 into main Aug 17, 2026
35 checks passed
@nedtwigg
nedtwigg deleted the fix/gradle-9.5-9.6-build-breakage branch August 17, 2026 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant