-
Notifications
You must be signed in to change notification settings - Fork 12
Remove redundant dependencies #166
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
base: main
Are you sure you want to change the base?
Conversation
Adds a new recipe that removes direct dependencies which are already provided transitively by another dependency matching a specified glob pattern. Only removes when the transitive version exactly matches. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Instead of relying on the project's resolved dependency tree (which merges direct dependencies), this downloads the parent dependency's POM and resolves it independently. This allows detecting redundancies even when both dependencies are explicitly declared. Also fixes GAV comparison to ignore datedSnapshotVersion field. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
src/main/java/org/openrewrite/java/dependencies/RemoveRedundantDependencies.java
Outdated
Show resolved
Hide resolved
Use specific Gradle configuration buckets instead of a single "all" bucket, with getBroaderGradleScopes to find transitives from broader configurations like api -> implementation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
@timtebeek I'm thinking through how using this recipe in conjunction with other recipes that change dependencies may lead to undesirable situations. Let's say we have a direct dependency I understand we have plenty of ways to get to a similar situation already, though we would probably want to use this recipe rather sparingly as we can't always easily account for all the overlap. If we only applied clearing out direct redundant dependencies based on those transitively available through our parent, that's a bit more of a focused scenario, at least, which sounds like could be a desired situation. Still reading through all the code for this EDIT: Ah, so I'm seeing that it's definitely for an intentioned removal of a specific dependency's transitives, so that alleviates some of the concern. |
|
Would it be worth adding a test example of something like: ...
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.0</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.17.0</version>
</dependency>
</dependencies>
...This may already be implicit due to it using the resolved POM, but could be a nice illustration of that fact. |
…pe (transitive `compile`) and a currently failing test for an exclusion scenario.
…d POM's `requestedDependencies` based on the exclusions present on the dependency in our project POM
Remove direct dependencies that are also brought in transitively by other direct dependencies.
Intended to be used when introducing spring boot starters to remove the direct dependencies they bring in.