Skip to content
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

A way to get all dependency instead ResolvedDependency only #4212

Open
abccbaandy opened this issue May 24, 2024 · 3 comments
Open

A way to get all dependency instead ResolvedDependency only #4212

abccbaandy opened this issue May 24, 2024 · 3 comments
Labels
recipe Requested Recipe

Comments

@abccbaandy
Copy link

What problem are you trying to solve?

I want to remove all dependency which already contain in others, especially for spring manage dependency.

Have you considered any alternatives or workarounds?

I just check the spring exist, but I don't think it's long-term solution.

Additional context

openrewrite/rewrite-migrate-java#481

Are you interested in contributing this feature to OpenRewrite?

Yes, I already start to study the source of DependencyInsight.
openrewrite/rewrite-migrate-java#481 (comment)

@abccbaandy abccbaandy added the enhancement New feature or request label May 24, 2024
@timtebeek timtebeek added recipe Requested Recipe and removed enhancement New feature or request labels May 24, 2024
@timtebeek
Copy link
Contributor

Thanks for the suggestion @abccbaandy ! I think this could be a separate recipe that folks can run to remove direct dependencies that are also available transitively. We already have that dependency insight readily available. A recipe would then have to use that information to strip out any dependencies.

Some care should be taken of course with scopes and optional dependencies, and you could end up with a pom.xml that's more sensitive to changes in transitive dependencies when updating dependency versions. But folks running this recipe likely would know those limitations, and still prefer a minimal pom.xml.

Thanks for the offer to help implement such a recipe! Would you be looking to add this first and only for Maven?

@timtebeek timtebeek moved this to Recipes Wanted in OpenRewrite May 24, 2024
@abccbaandy
Copy link
Author

abccbaandy commented May 24, 2024

Yes, I already did it, you can see openrewrite/rewrite-migrate-java#481 (comment)
I quote some relate text here.

  1. The DependencyInsight seems not support non-ResolvedDependency.
    Means when we have direct dependency, the transitive dependency with the same name is gone.
    ref
    https://github.com/openrewrite/rewrite/blob/main/rewrite-maven/src/main/java/org/openrewrite/maven/search/DependencyInsight.java#L119
    So, I guess this issue cause DependencyInsight onlyTransitive feature not possible.

@timtebeek
Copy link
Contributor

Ah so you're saying that our model currently only gives you the resolved dependency, but you're losing out on querying if that dependency is also available transitively? I could see how that would complicate this recipe if that's the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe Requested Recipe
Projects
Status: Recipes Wanted
Development

No branches or pull requests

2 participants