Skip to content

Continue refinements of AddSettingsPluginRepository#7132

Merged
timtebeek merged 1 commit intomainfrom
shanman190/gradle/add-plugin-repository
Mar 25, 2026
Merged

Continue refinements of AddSettingsPluginRepository#7132
timtebeek merged 1 commit intomainfrom
shanman190/gradle/add-plugin-repository

Conversation

@shanman190
Copy link
Copy Markdown
Contributor

@shanman190 shanman190 commented Mar 25, 2026

What's changed?

  • Fixes the AddSettingsPluginRepository recipe to correctly handle pluginManagement block placement in Gradle settings files, and corrects invalid test examples introduced in Fix AddSettingsPluginRepository duplicate pluginManagement when not first statement #7105.

  • Insertion of new pluginManagement blocks now skips past any leading import statements before inserting at position 0

  • Removed Groovy DSL tests that placed rootProject.name before pluginManagement (invalid in Groovy — "The pluginManagement {} block must appear before any other statements in the script")

  • Retained Kotlin DSL "not first statement" tests with rootProject.name before pluginManagement (valid in Kotlin DSL)

  • Added noPluginManagementBlockWithBuildCacheKts test covering the customer-reported scenario where buildCache exists and pluginManagement must be inserted before it

What's your motivation?

Verified with Gradle 9.3.1:

  • Groovy DSL: pluginManagement must be the absolute first statement (only imports may precede it). buildscript, buildCache, rootProject.name — all fail if placed before it.
  • Kotlin DSL: pluginManagement can appear after most blocks (buildCache, rootProject.name, include()), but buildscript cannot appear before it.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@shanman190 shanman190 self-assigned this Mar 25, 2026
@shanman190 shanman190 added enhancement New feature or request recipe Requested Recipe gradle labels Mar 25, 2026
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Mar 25, 2026
@shanman190 shanman190 changed the title Continue refinements of AddPluginRepository Continue refinements of AddSettingsPluginRepository Mar 25, 2026
Copy link
Copy Markdown
Member

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Mar 25, 2026
@timtebeek timtebeek merged commit 519950d into main Mar 25, 2026
1 check passed
@timtebeek timtebeek deleted the shanman190/gradle/add-plugin-repository branch March 25, 2026 07:48
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request gradle recipe Requested Recipe

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants