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

Migrate from com.intellij:annotations to org.jetbrains:annotations #289

Open
yeikel opened this issue Aug 31, 2023 · 10 comments
Open

Migrate from com.intellij:annotations to org.jetbrains:annotations #289

yeikel opened this issue Aug 31, 2023 · 10 comments
Labels
good first issue Good for newcomers recipe Recipe requested

Comments

@yeikel
Copy link
Contributor

yeikel commented Aug 31, 2023

What problem are you trying to solve?

The com.intellij:annotations package was relocated to org.jetbrains:annotations after v12 (2013)

This caused confusion and many teams are unaware and still using the old coordinates.

Describe the situation after applying the recipe

There are various examples, but here is one :

import com.intellij.annotations.NotNull
-import com.intellij.annotations.NotNull
+import org.jetbrains.annotations.NotNull
@yeikel yeikel changed the title Migrate from com.intellij:annotations -> org.jetbrains:annotations Migrate from com.intellij:annotations to org.jetbrains:annotations Aug 31, 2023
@timtebeek
Copy link
Contributor

Good suggestion, and should be an easy change. Could even fold that under the existing efforts we have for nullability annotations

@yeikel
Copy link
Contributor Author

yeikel commented Sep 7, 2023

This would go beyond nullability as there are many other annotations within that package. I supposed that we can target nullability as a first step

@timtebeek
Copy link
Contributor

So I'm seeing a number of different artifacts related to this:

  1. https://mvnrepository.com/artifact/com.intellij/annotations v12
  2. https://mvnrepository.com/artifact/org.jetbrains/annotations v24.0.1
  3. https://mvnrepository.com/artifact/com.jetbrains/annotations v2022.3

The oldest and smallest 1 seems to have moved to 2, while 3 contains a smaller subset of 2.

All three seem to use org.jetbrains and org.intellij as packages though; didn't spot any com.intellij in any. Where did you see those?

@timtebeek
Copy link
Contributor

Since there's multiple classes and artifacts involved here I'd suggest we start with a declarative recipe that changes GAVs and package names, such that users are able to switch from older dependencies to latest. Likely something that best fits into rewrite-migrate-java until we have a better place for these.

Should possible to mostly compose these through https://app.moderne.io/recipes/builder and add some tests for good measure.
I expect the use of

Could you provide the details on what older GAV had the com.intellij package previously, and perhaps even a starter for the recipe replacements?

@timtebeek timtebeek added good first issue Good for newcomers recipe Recipe requested labels Sep 13, 2023
@timtebeek timtebeek transferred this issue from openrewrite/rewrite Sep 13, 2023
@yeikel
Copy link
Contributor Author

yeikel commented Sep 14, 2023

Since there's multiple classes and artifacts involved here I'd suggest we start with a declarative recipe that changes GAVs and package names, such that users are able to switch from older dependencies to latest. Likely something that best fits into rewrite-migrate-java until we have a better place for these.

Should possible to mostly compose these through https://app.moderne.io/recipes/builder and add some tests for good measure. I expect the use of

Could you provide the details on what older GAV had the com.intellij package previously, and perhaps even a starter for the recipe replacements?

I am a bit confused as to why you cannot see the coordinates but this is an example :

https://mvnrepository.com/artifact/com.intellij/annotations/12.0

<dependency>
    <groupId>com.intellij</groupId>
    <artifactId>annotations</artifactId>
    <version>12.0</version>
</dependency>

image

Could you please clarify what you mean?

@timtebeek
Copy link
Contributor

image

Could you please clarify what you mean?

I meant that if I open the 12.0 jar, I only see classes in the org.jetbrains package, not the com.intellij you mentioned at the start.
image

I'm wondering if there's a separate fourth (?) GAV coordinate we need to resolve the types in com.intellij and move those over to org.jetbrains.

@yeikel
Copy link
Contributor Author

yeikel commented Sep 14, 2023

image
Could you please clarify what you mean?

I meant that if I open the 12.0 jar, I only see classes in the org.jetbrains package, not the com.intellij you mentioned at the start. image

I'm wondering if there's a separate fourth (?) GAV coordinate we need to resolve the types in com.intellij and move those over to org.jetbrains.

Ah, I see what you mean now. That's interesting (and surprising).

I assumed that the imports would be the same(sorry about that) but I have only seen the artifacts in my projects.

I did some additional checks but even version 5.1(from 2006) contains the org.jetbrains package so perhaps we do not need to change the package, and that's good news for us

@yeikel
Copy link
Contributor Author

yeikel commented Sep 14, 2023

I did additional digging, but I could not find any version before 5.1

https://repo1.maven.org/maven2/com/intellij/annotations/

@yeikel
Copy link
Contributor Author

yeikel commented Sep 14, 2023

One more interesting metric is that according to Maven central, this is used in 4309 components

@timtebeek
Copy link
Contributor

One more interesting metric is that according to Maven central, this is used in 4309 components

Guess we have a declarative recipe to write and execute through Moderne! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers recipe Recipe requested
Projects
Status: Backlog
Development

No branches or pull requests

2 participants