Migrate deprecated javax.annotation to jakarta.annotation

MSAL

Java EE has been rebranded to Jakarta EE, necessitating a package relocation. JSR-305 annotations such as javax.annotation.Nonnull, which share the javax.annotation package, are left unchanged.

org.openrewrite.java.migrate.jakarta.JavaxAnnotationMigrationToJakartaAnnotation
mod run . --recipe=org.openrewrite.java.migrate.jakarta.JavaxAnnotationMigrationToJakartaAnnotation

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Change Gradle or Maven dependency javax.annotation:jsr250-api
  2. Change Gradle or Maven dependency javax.annotation:javax.annotation-api
  3. Change Gradle or Maven dependency org.glassfish.main:javax.annotation
  4. Upgrade Gradle or Maven dependency versions jakarta.annotation:jakarta.annotation-api:2.0.x
  5. Add the Jakarta Annotation API when needed
  6. Add an API dependency for explicit imports
  7. Change type javax.annotation.Generated to jakarta.annotation.Generated
  8. Change type javax.annotation.ManagedBean to jakarta.annotation.ManagedBean
  9. Change type javax.annotation.PostConstruct to jakarta.annotation.PostConstruct
  10. Change type javax.annotation.PreDestroy to jakarta.annotation.PreDestroy
  11. Change type javax.annotation.Priority to jakarta.annotation.Priority
  12. Change type javax.annotation.Resource to jakarta.annotation.Resource
  13. Change type javax.annotation.Resources to jakarta.annotation.Resources
  14. Rename package name javax.annotation.security to jakarta.annotation.security
  15. Rename package name javax.annotation.sql to jakarta.annotation.sql