quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.39k stars 2.57k forks source link

Migrate javax to jakarta for elements in annotation attributes in package-info.java #33157

Open apupier opened 1 year ago

apupier commented 1 year ago

Description

When applying the Quarkus migration tool, this package-info.java file is partially migrated:

@XmlSchema(namespace = "https://www.lfenergy.org/compas/example", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package org.lfenergy.compas.core.commons.model;

import javax.xml.bind.annotation.XmlSchema;

to:

@XmlSchema(namespace = "https://www.lfenergy.org/compas/example", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package org.lfenergy.compas.core.commons.model;

import jakarta.xml.bind.annotation.XmlSchema;

it would be convenient to migrate also the class referenced in the attribute of the annotation:

@XmlSchema(namespace = "https://www.lfenergy.org/compas/example", elementFormDefault = jakarta.xml.bind.annotation.XmlNsForm.QUALIFIED)
package org.lfenergy.compas.core.commons.model;

import jakarta.xml.bind.annotation.XmlSchema;

this example comes from https://github.com/com-pas/compas-core/blob/0.14.0/commons/src/test/java/org/lfenergy/compas/core/commons/model/package-info.java

Implementation ideas

No response

apupier commented 1 year ago

If i understand well, Quarkus is relying on OpenRewrite https://github.com/quarkusio/quarkus/blob/d45c5478cf4c27add37822f1a45510cde7c7c481/independent-projects/tools/devtools-common/src/main/resources/openrewrite-init.gradle#L10 , and on https://docs.openrewrite.org/recipes/java/migrate/jakarta/javaxxmlbindmigrationtojakartaxmlbind in this specific case.

Which itself relies on https://docs.openrewrite.org/recipes/java/changepackage#source based on https://github.com/openrewrite/rewrite-migrate-java/blob/248045c9ce6d839db05cf4d52508f74f2b844f32/src/main/resources/META-INF/rewrite/jakarta-ee-9.yml#L816

So it would mean that it is an issue coming from OpenRewrite itself.

geoand commented 1 year ago

cc @gsmet @maxandersen

gastaldi commented 1 year ago

Definitely a bug in OpenRewrite. Here is the recipe that should perform the package change:

https://github.com/quarkusio/quarkus-updates/blob/main/recipes/src/main/resources/quarkus-updates/core/3alpha.yaml#L1057C5-L1060