Skip to content

Skip plugins block in UsePropertyAssignmentSyntax#7337

Merged
timtebeek merged 2 commits intomainfrom
tim/gradle-plugins-equals
Apr 9, 2026
Merged

Skip plugins block in UsePropertyAssignmentSyntax#7337
timtebeek merged 2 commits intomainfrom
tim/gradle-plugins-equals

Conversation

@timtebeek
Copy link
Copy Markdown
Member

@timtebeek timtebeek commented Apr 9, 2026

Summary

  • UsePropertyAssignmentSyntax was incorrectly transforming version '3.19' inside plugins { } blocks to .version = '3.19'
  • In Gradle's plugins DSL, version is part of the declaration syntax, not a property assignment
  • Fixed by skipping recursion into plugins blocks entirely — the visitor returns early without calling super.visitMethodInvocation, so children of the plugins block are never visited

Test plan

  • Added test for settings.gradle plugins block (pluginVersionUnchangedInPluginsBlock)
  • Added test for build.gradle plugins block (pluginVersionUnchangedInBuildGradlePluginsBlock)
  • Added test confirming version outside plugins block still converts (versionOutsidePluginsBlockConverted)
  • All existing tests still pass

The recipe was incorrectly converting `version '3.19'` inside
`plugins { }` blocks to `.version = '3.19'`. In the Gradle plugins
DSL, `version` is part of the plugin declaration syntax, not a
property assignment. Walk the cursor tree to detect and skip
method invocations inside plugins blocks.
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Apr 9, 2026
@timtebeek timtebeek marked this pull request as draft April 9, 2026 20:16
Instead of checking cursor ancestry on each match, skip
the super.visitMethodInvocation call for plugins blocks
so their children are never visited.
@timtebeek timtebeek marked this pull request as ready for review April 9, 2026 20:18
@timtebeek timtebeek merged commit a46a5ac into main Apr 9, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Apr 9, 2026
@timtebeek timtebeek deleted the tim/gradle-plugins-equals branch April 9, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant