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

Remove Jakarta annotation dependency when moving to Jakarta packages #487

Merged

Conversation

abccbaandy
Copy link
Contributor

@abccbaandy abccbaandy commented May 22, 2024

What's changed?

Add a recipe to revert the jakarta.annotation-api added by org.openrewrite.java.migrate.javax.AddCommonAnnotationsDependencies

What's your motivation?

Fix #481

Anyone you would like to review specifically?

@timtebeek

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

Comment on lines 998 to 1001
recipeList:
- org.openrewrite.java.dependencies.DependencyInsight:
groupIdPattern: jakarta.annotation
artifactIdPattern: jakarta.annotation-api
Copy link
Contributor

Choose a reason for hiding this comment

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

Preconditions are the typical way to limit what files recipes operate on. That would look something like this

Suggested change
recipeList:
- org.openrewrite.java.dependencies.DependencyInsight:
groupIdPattern: jakarta.annotation
artifactIdPattern: jakarta.annotation-api
preconditions:
- org.openrewrite.java.dependencies.DependencyInsight:
groupIdPattern: jakarta.annotation
artifactIdPattern: jakarta.annotation-api
recipeList:

I'm not sure about the use of DependencyInsight here though, as we likely only want to remove the dependency if it's already available transitively. That might need some custom logic. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, not just found.
We need find in transitively "only", is this possible with DependencyInsight?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not right now; we do have an onlyDirect option on that recipe, but perhaps we'd need to add an onlyTransitive:
https://docs.openrewrite.org/recipes/maven/search/dependencyinsight#dependencies-in-use

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, guess we can only postpone this PR until DependencyInsight support onlyTransitive? 😢

Copy link
Contributor

Choose a reason for hiding this comment

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

Possibly yes. Although that might not be too difficult as we already know the depth there, since we add that to the data table we produce.

Copy link
Contributor Author

@abccbaandy abccbaandy May 24, 2024

Choose a reason for hiding this comment

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

How?
Just like my comment 1. said, it's gone.

I can submit PR with the failed test if you want.

@timtebeek timtebeek marked this pull request as draft May 22, 2024 11:28
@timtebeek timtebeek changed the title draft for RemoveJakartaAnnotationDependency Remove Jakarta annotation dependency when moving to Jakarta packages May 22, 2024
@abccbaandy abccbaandy marked this pull request as ready for review May 24, 2024 06:10
@abccbaandy
Copy link
Contributor Author

I check if contain spring boot starter instead, because this.
I think this PR is done now if no other better way.

@abccbaandy abccbaandy requested a review from timtebeek May 24, 2024 06:13
Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

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

Thanks a lot for restoring this functionality. Should be good to see the jakarta annotation removed in the common case of using a spring-boot-starter.

@timtebeek timtebeek merged commit 110db88 into openrewrite:main May 24, 2024
2 checks passed
@timtebeek timtebeek added bug Something isn't working enhancement New feature or request recipe Recipe requested labels May 24, 2024
@abccbaandy
Copy link
Contributor Author

@timtebeek
Just curious, when can we test this in latest version?

@timtebeek
Copy link
Contributor

Hi! It's not yet I'm the latest release, but should be in the latest snapshot version. We release every two weeks. Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request recipe Recipe requested
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

jakarta.annotation-api dependency added in Java 11 migration should be removed when migrating to Jakarta
2 participants