-
Notifications
You must be signed in to change notification settings - Fork 80
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
jakarta.annotation-api
dependency added in Java 11 migration should be removed when migrating to Jakarta
#481
Comments
Hi @abccbaandy ; thanks for the report! Good to see the recipes that made changes included here; that helps reference the code. The dependency is added from this recipe step rewrite-migrate-java/src/main/resources/META-INF/rewrite/add-common-annotations-dependencies.yml Lines 35 to 40 in 64f8669
Notice how it's constrained to only add the dependency if you are using anything from the Could you let me know why you feel we should not add that dependency to your project in this case? |
Hi @timtebeek , the Spring boot version was 2.X, so yes, I am use javax.annotation. But for the Also, since the spring boot starter contain the jakarta.annotation dependency and maintain the version already, I don't think it's right to add jakarta relate dependency, |
Thanks for that additional context! I think I have an understanding now of what's going on. We recently added an explicit recipe to change or add The Java 11 migration is also run as part of a Spring Boot 3 migration, as that includes Java 17 migration, which includes Java 11. I imagine we could add a recipe to Is this something you'd already be comfortable adding to src/main/resources/META-INF/rewrite/jakarta-ee-9.yml ? Even a draft PR with a unit test would be welcome; if not I'll try to fit it in but that could be a little while, as it's hard to get to everything. |
jakarta.annotation-api
dependency added in Java 11 migration should be removed when migrating to Jakarta
I see you've started working toward this @abccbaandy ; thanks a lot! Feel free to open a draft pull request such that I can help out if needed. |
lol how do you found that? Anyways, I open a PR with some question, please help. |
Hi @timtebeek I have some new thought about this issue after study the source.
applicability:
singleSource:
- org.openrewrite.maven.search.DoesNotIncludeDependency:
groupId: org.springframework.boot
artifactId: spring-boot-starter-web https://github.com/nmck257/rewrite-migrate-java/blob/29319b419d1daa228abd8ebc6958b1f3f725a8b2/src/main/resources/META-INF/rewrite/jakarta-ee-9.yml#L696 But it got removed in the latest master, I don't know why. Can we use the same way to modify the |
Ah yes single-source applicability tests is what we called preconditions in Rewrite v7; I suspect it was dropped as we moved to Rewrite v8 and not revisited since. I can see that DoesNotIncludeDependency recipe itself does use DependencyInsight, with a hint about use with multi module projects. If we can make that work well as a precondition to check for the absence/presence of a transitive(!) dependency, for instance by looking at the |
This is a workaround, reason:openrewrite#481 (comment)
…487) * draft for RemoveJakartaAnnotationDependency * Apply suggestions from code review * add negative test * find spring boot only This is a workaround, reason:#481 (comment) * Minor polish --------- Co-authored-by: Tim te Beek <[email protected]> Co-authored-by: Tim te Beek <[email protected]>
What version of OpenRewrite are you using?
I am using IntelliJ IDEA OpenRewrite feature, guess it's latest version? It didn't print the version :(
How are you running OpenRewrite?
with this recipes only
What is the smallest, simplest way to reproduce the problem?
N/A
What did you expect to see?
Noting.
What did you see instead?
in build.gradle, it add this line
What is the full stack trace of any errors you encountered?
N/A
But here is the log relate to this issue
Are you interested in contributing a fix to OpenRewrite?
Sure, let me know what can I do.
The text was updated successfully, but these errors were encountered: