Skip to content

fix: plugin block matching for Gradle refactoring#66

Merged
vpa1977 merged 9 commits intocanonical:mainfrom
vpa1977:nested_brace
Dec 11, 2025
Merged

fix: plugin block matching for Gradle refactoring#66
vpa1977 merged 9 commits intocanonical:mainfrom
vpa1977:nested_brace

Conversation

@vpa1977
Copy link
Copy Markdown
Contributor

@vpa1977 vpa1977 commented Dec 9, 2025

Fix refactoring for gradle builds:

  • change rule to accept plugin block rather than plugins token (this fixes issue when plugin definition was added after plugin.
  • allow nested braces in plugin block, this fixes issue when plugin was inserted in version variable, e.g. foo.bar:foo:${foo-version}

@vpa1977 vpa1977 changed the title fix: allow nested braces in plugin block fix: plugin block matching for Gradle refactoring Dec 10, 2025
@vpa1977 vpa1977 requested a review from Copilot December 10, 2025 23:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Gradle plugin block matching in the refactoring logic to handle edge cases where plugin definitions are added after plugin. tokens and when version strings contain nested braces (e.g., ${foo-version}).

Key changes:

  • Modified the ANTLR grammar to accept the plugin block rule instead of just the plugins token, and added support for nested braces within plugin blocks
  • Updated the listener to match on RULE_plugin instead of PLUGINS token
  • Added test coverage for the refactoring with nested braces in version strings

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/main/antlr/com/canonical/devpackspring/build/grammar/GradlePlugin.g4 Updated grammar rules to handle nested braces in plugin blocks and changed plugin_block definition
src/main/java/com/canonical/devpackspring/build/gradle/FindPluginListener.java Changed rule matching from PLUGINS token to RULE_plugin
src/main/java/com/canonical/devpackspring/build/gradle/Refactoring.java Added error listener suppression for cleaner output
src/test/java/com/canonical/devpackspring/build/gradle/RefactoringTests.java Added test case for refactoring with nested braces in version strings
test-data/projects/gradle-kotlin/build.gradle.kts Added test fixture with plugins.withType block
gradle.properties Bumped version from 0.12.0 to 0.12.2

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Vladimir Petko <vladimir.petko@canonical.com>
@vpa1977 vpa1977 requested a review from Copilot December 10, 2025 23:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Vladimir Petko <vladimir.petko@canonical.com>
@vpa1977 vpa1977 requested a review from Copilot December 10, 2025 23:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

vpa1977 and others added 2 commits December 11, 2025 12:40
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Vladimir Petko <vladimir.petko@canonical.com>
@vpa1977 vpa1977 requested a review from pushkarnk December 11, 2025 00:02
@vpa1977 vpa1977 merged commit b3096ab into canonical:main Dec 11, 2025
1 check passed
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.

3 participants