Skip to content

Fix Gradle 9.4 variant model cycle without GCV workaround#150

Closed
FinlayRJW wants to merge 5 commits intodevelopfrom
finlayw/fix-gradle9-variant-resolution-subproject
Closed

Fix Gradle 9.4 variant model cycle without GCV workaround#150
FinlayRJW wants to merge 5 commits intodevelopfrom
finlayw/fix-gradle9-variant-resolution-subproject

Conversation

@FinlayRJW
Copy link
Contributor

@FinlayRJW FinlayRJW commented Mar 10, 2026

Before this PR

On Gradle 9.4+ with gradle-consistent-versions, a variant model cycle occurs:

Could not resolve root project :.
  > Value for variants of root project : has not been calculated yet.

This plugin applied IdeaLanguageInjectorProjectPlugin to all projects including the root via allprojects {}, creating a consumable config on the root project. GCV makes all configs extend its rootConfiguration (which has a ProjectDependency on root), creating a self-referencing cycle during variant model computation.

#149 worked around this with VersionRecommendationsExtension.excludeConfigurations(...), but that required a compile-time dependency on GCV. See also palantir/gradle-consistent-versions#1614 for the GCV-side fix.

After this PR

Fixes the architectural issue: the root project shouldn't have a consumable config since it's the aggregator/consumer.

  • allprojects {}subprojects {} so the consumable config is only created on subprojects
  • Root project Java dependencies are scanned directly via sourceSetArtifactView() with the artifact transform, bypassing the consumable config entirely
  • Removed the GCV excludeFromConsistentVersions workaround and compileOnly dependency
  • Unified sourceSetArtifacts/sourceSetArtifactView into a single parameterized method

@changelog-app
Copy link

changelog-app bot commented Mar 10, 2026

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

Fix Gradle 9.4 variant model cycle without GCV workaround

Check the box to generate changelog(s)

  • Generate changelog entry

@FinlayRJW FinlayRJW changed the base branch from develop to finlayw/fix-gradle9-variant-resolution March 10, 2026 15:59
@FinlayRJW FinlayRJW changed the base branch from finlayw/fix-gradle9-variant-resolution to develop March 10, 2026 16:01
@changelog-app
Copy link

changelog-app bot commented Mar 10, 2026

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

Fix Gradle 9.4 variant model cycle without GCV workaround

Check the box to generate changelog(s)

  • Generate changelog entry

@changelog-app
Copy link

changelog-app bot commented Mar 10, 2026

Successfully generated changelog entry!

Need to regenerate?

Simply interact with the changelog bot comment again to regenerate these entries.


📋Changelog Preview

💡 Improvements

  • Fix Gradle 9.4 variant model cycle without GCV workaround (#150)

@FinlayRJW
Copy link
Contributor Author

closed in favour of palantir/gradle-consistent-versions#1614

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant