-
Notifications
You must be signed in to change notification settings - Fork 500
Bug: Incorrect plugin insertion order in settings.gradle with pluginManagement and buildscript #6478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Incorrect plugin insertion order in settings.gradle with pluginManagement and buildscript #6478
Conversation
|
Thanks for getting this started @div-bargali ; At first glance these tests look good to me! |
rewrite-gradle/src/test/java/org/openrewrite/gradle/plugins/AddSettingsPluginTest.java
Outdated
Show resolved
Hide resolved
|
Both tests also look good to me too! |
…bility and maintainability
…dscript in settings.gradle(.kts)
rewrite-gradle/src/main/java/org/openrewrite/gradle/plugins/AddPluginVisitor.java
Outdated
Show resolved
Hide resolved
|
Added the fix for the bug @timtebeek. I also noticed that in the Kotlin script handling section, the AST was parsed incorrectly for the (.kts) files. Due to this, the kotlin login in I have included the fix for that too in this PR. |
…dPluginVisitor.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
rewrite-gradle/src/test/java/org/openrewrite/gradle/plugins/AddSettingsPluginTest.java
Outdated
Show resolved
Hide resolved
rewrite-gradle/src/test/java/org/openrewrite/gradle/plugins/AddSettingsPluginTest.java
Outdated
Show resolved
Hide resolved
timtebeek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the help here @div-bargali ; that a parallel effort was started accidentally only speaks to that you've picked a worthwhile issue to fix, and I like the approach you took here.
What's changed?
Added failing unit tests to demonstrate incorrect plugin ordering in
settings.gradle[.kts]files when bothpluginManagementandbuildscriptblocks are present.New tests added:
addPluginWithPluginManagementAndBuildscriptBlocks()- Groovy DSL testaddPluginWithPluginManagementAndBuildscriptBlocksKotlin()- Kotlin DSL testThese tests currently fail because
AddPluginVisitorincorrectly inserts thepluginsblock betweenpluginManagementandbuildscript, violating Gradle's required ordering.What's your motivation?
When
AddSettingsPluginis applied to asettings.gradlefile containing bothpluginManagementandbuildscriptblocks, it produces invalid Gradle syntax that causes build failures with the error:only buildscript {} and other plugins {} script blocks are allowed before plugins {} block
Anything in particular you'd like reviewers to focus on?
interpolateResolvedVersionKotlin()helper method for Kotlin testsAny additional context
This PR includes the failing tests to document the bug before implementing the fix. The fix will be submitted in a follow-up commit.
Impact: This issue affects any project using
AddSettingsPluginon settings files that contain bothpluginManagementandbuildscriptblocks.Checklist