Skip to content

RemoveRedundantDependencyVersions recipe removes direct dependencies if dependency is pulled in transitively #5409

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

Merged

Conversation

jevanlingen
Copy link
Contributor

What's changed?

Redundant direct dependencies are removed as well.

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

Interestingly, the recipe did remove direct dependencies with a lower version number already. This was actually a side effect by removing redundant constraints. I just added an extra check to see if the version

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

@jevanlingen jevanlingen added the recipe Requested Recipe label May 9, 2025
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite May 9, 2025
@JohannisK JohannisK requested a review from shanman190 May 15, 2025 11:41
Copy link
Contributor

@shanman190 shanman190 left a comment

Choose a reason for hiding this comment

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

optional: should we also consider moving from Groovy visitors to the more general Java visitors in order to bring Kotlin DSL support to this recipe? There doesn't appear to be any specific functionality used, so it should be a pretty straight forward class swap.

@sambsnyd
Copy link
Member

The Maven version of this recipe has controls to allow the user to specify when to remove. If we have the same options on the gradle recipe we can group them together into a single remove-redundants in rewrite-java-dependencies

@JohannisK JohannisK marked this pull request as ready for review May 21, 2025 10:45
@sambsnyd sambsnyd merged commit 7ad7157 into main May 22, 2025
2 checks passed
@sambsnyd sambsnyd deleted the remove-redundant-dependency-versions-removeDirectDependencies branch May 22, 2025 17:19
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite May 22, 2025
knutwannheden pushed a commit that referenced this pull request May 23, 2025
…if dependency is pulled in transitively (#5409)

* RemoveRedundantDependencyVersions recipe removes direct dependencies if dependency is pulled in transitively

* Polish

* Can handle several boms

* Added sorting to find highest dependency managed version

* cleanup

* extracted method out of loop

* improved name, removed unused option

* Added support for kotlin, added support for all dependency management methods.

* renamed method

* reverted temporary assignment for debug purposes

---------

Co-authored-by: Johan Kragt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe Requested Recipe
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants