Skip to content

Conversation

shanman190
Copy link
Contributor

@shanman190 shanman190 commented Jun 6, 2025

What's changed?

Added a trait implementing to find direct and transitive Gradle plugins and relevant information about them.

What's your motivation?

More traits? 😆

Anything in particular you'd like reviewers to focus on?

Nothing in particular

Anyone you would like to review specifically?

Anybody.

Have you considered any alternatives or workarounds?

N/A

Any additional context

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 Jun 6, 2025
@shanman190 shanman190 added the enhancement New feature or request label Jun 6, 2025
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Jun 6, 2025
@shanman190 shanman190 force-pushed the feature/gradle-plugin-trait branch from 9b61b8b to a33a494 Compare June 6, 2025 21:56
@shanman190
Copy link
Contributor Author

shanman190 commented Jun 7, 2025

It would be most ideal that the FieldAccess and Identifier cases were able to specify the full class name via type attribution. Unfortunately, the types weren't available even after adding the OpenRewrite plugin to the classpath.

I didn't feel comfortable either with forcing the class name in from either value due to the possibility of all other kinds of code combinations that could arise from real world usage.

TODOs:

  • Add alias support from Gradle Version Catalogs. Like FieldAccess and Identifier, this probably won't carry much useful information at first due to the lack thereof in the model and markers.
  • Add test case for settings.gradle(.kts)

@timtebeek timtebeek requested review from Jenson3210 and sambsnyd June 7, 2025 12:01
@Jenson3210
Copy link
Contributor

I think this is awesome!
If possible, we could enhance it with the versions if the version itself is declared higher up / somewhere else in the cursor.
But if not possible in an accurate way, we can also leave it.

@timtebeek timtebeek moved this from In Progress to Ready to Review in OpenRewrite Jun 16, 2025
@timtebeek timtebeek requested a review from jkschneider June 16, 2025 23:10
void alias() {
rewriteRun(
spec -> spec.recipe(RewriteTest.toRecipe(() -> new GradlePlugin.Matcher().asVisitor(plugin -> SearchResult.found(plugin.getTree())))),
toml(
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if we should have a gradleVersionCatalog() or similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely a good candidate for a potential helper method. The default file name that is picked up automatically by Gradle is gradle/libs.versions.toml, so we'd probably align in some capacity to that if we chose to adopt such a helper.

@sambsnyd sambsnyd merged commit f1dd96f into main Jul 22, 2025
2 checks passed
@sambsnyd sambsnyd deleted the feature/gradle-plugin-trait branch July 22, 2025 19:11
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Jul 22, 2025
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

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants