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

Recipe UpgradeSpringBoot_3_3 misses upgrading wro4j-maven-plugin and the latest version of jakarta.xml.bind-api when the origin is Java8 and Spring Boot 1.5.X #4283

Closed
mgvinuesa opened this issue Jun 24, 2024 · 6 comments
Labels
bug Something isn't working question Further information is requested

Comments

@mgvinuesa
Copy link

mgvinuesa commented Jun 24, 2024

What version of OpenRewrite are you using?

I am using:

  • Maven/Gradle plugin 5.34.0
  • rewrite-spring 5.13.2

How are you running OpenRewrite?

I'm using maven plugin on my own project.

You can check the project here:
https://github.com/mgvinuesa/spring-petclinic-openrewrite

It is a fork of spring-petclinic and you might use the branch with the name migrate_with_open_rewrite, I started with the TAG 1.5.x to migrate boot Spring Boot and Java using OpenRewrite.

What is the smallest, simplest way to reproduce the problem?

Execute the mvn command with the current configuration with Java 8.

mvn rewrite:run

What did you expect to see?

The wro4j-maven-plugin might upgrade from 1.8.0 to 2.X due to Java17 compatibility.
The recipe that adds jakarta.xml.bind-api must include the latest version instead of 2.3.3.

What did you see instead?

Even there is a recipe to work with wro4j:

org.openrewrite.java.migrate.UpgradeToJava17
[WARNING]                         org.openrewrite.java.migrate.Java8toJava11
[WARNING]                             org.openrewrite.java.migrate.javax.AddJaxbDependencies
[WARNING]                                 org.openrewrite.java.dependencies.AddDependency: {groupId=jakarta.xml.bind, artifactId=jakarta.xml.bind-api, version=2.3.x, onlyIfUsing=javax.xml.bind..*, acceptTransitive=true}
[WARNING]                             org.openrewrite.java.migrate.cobertura.RemoveCoberturaMavenPlugin
[WARNING]                                 org.openrewrite.maven.RemovePlugin: {groupId=org.codehaus.mojo, artifactId=cobertura-maven-plugin}
[WARNING]                             org.openrewrite.java.migrate.wro4j.UpgradeWro4jMavenPluginVersion
[WARNING]                                 org.openrewrite.maven.UpgradePluginVersion: {groupId=ro.isdc.wro4j, artifactId=wro4j-maven-plugin, newVersion=1.10.1}

Nothing happens, but the version is for Java11, not for Java17.

On the other side, about jakarta, the recipe AddDependency

[WARNING]                     org.openrewrite.java.migrate.UpgradeToJava17
[WARNING]                         org.openrewrite.java.migrate.Java8toJava11
[WARNING]                             org.openrewrite.java.migrate.javax.AddJaxbDependencies
[WARNING]                                 org.openrewrite.java.dependencies.AddDependency: {groupId=jakarta.xml.bind, artifactId=jakarta.xml.bind-api, version=2.3.x, onlyIfUsing=javax.xml.bind..*, acceptTransitive=true}

Add the 2.3.3 dependency but it is not enough due to packaging error with Java17, this dependency still use javax.xml.bind package.

Apart from that, I have tried to add more recipes to solve these issues:

---
type: specs.openrewrite.org/v1beta/recipe
name: com.example.MigrateToSpringBoot3_3
displayName: Upgrade Wro4j Maven plugin version
causesAnotherCycle: true
recipeList:
    - org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3
    - org.openrewrite.maven.UpgradePluginVersion:
        groupId: ro.isdc.wro4j
        artifactId: wro4j-maven-plugin
        newVersion: 2.1.1
    - org.openrewrite.maven.RemoveProperty:
        propertyName: cobertura.version
    - org.openrewrite.maven.UpgradeDependencyVersion:
        groupId: jakarta.xml.bind
        artifactId: jakarta.xml.bind-api
        newVersion: 4.0.2

But the last recipe, UpgradeDependencyVersion, does not execute although I have tried to put causesAnotherCycle = true. So if you put this recipe com.example.MigrateToSpringBoot3_3 instead of org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3 you can see that jakarta.xml.bind-api` is not upgraded.

What is the full stack trace of any errors you encountered?

No errors, only the result is not the proper one.

Are you interested in [contributing a fix to OpenRewrite]

Currently im writing a post in spanish about it, it is pretty interesting, if I had time i would like to fix this problem.

@mgvinuesa mgvinuesa added the bug Something isn't working label Jun 24, 2024
@timtebeek
Copy link
Contributor

The wro4j dependency should be updated, as part of our Java 11 migration, as seen in rewrite-migrate-java:
https://github.com/openrewrite/rewrite-migrate-java/blob/724a2442755b5bde6f8cdd225db7eab531108a70/src/main/resources/META-INF/rewrite/wro4j-maven-plugin.yml#L17-L28

Also: welcome to let me know if there's anything you'd like be to proofread. Happy to help!

@mgvinuesa
Copy link
Author

mgvinuesa commented Jun 24, 2024

Hello @timtebeek

I just update the plugin with the following SNAPSHOT versions:

rewrite-maven-plugin: 5.35.5-SNAPSHOT
rewrite-spring: 5.14.0-SNAPSHOT

The result is the following:

  1. The jakarta xml api dependency still appears with the wrong version
    <dependency>
      <groupId>jakarta.xml.bind</groupId>
      <artifactId>jakarta.xml.bind-api</artifactId>
      <version>2.3.3</version>
    </dependency>
[INFO] �[1m--- �[0;32mrewrite:5.35.0-SNAPSHOT:run�[m �[1m(default-cli)�[m @ �[36mspring-petclinic�[0;1m ---�[m
org.openrewrite.java.migrate.UpgradeToJava17
[WARNING]                         org.openrewrite.java.migrate.Java8toJava11
[WARNING]                             org.openrewrite.java.migrate.javax.AddJaxbDependencies
[WARNING]                                 org.openrewrite.java.dependencies.AddDependency: {groupId=jakarta.xml.bind, artifactId=jakarta.xml.bind-api, version=2.3.x, onlyIfUsing=javax.xml.bind..*, acceptTransitive=true}

I think that this recipe org.openrewrite.java.migrate.jakarta.JavaxMigrationToJakarta executed after must include the group and the artifact id related with the previous dependency.

Regarding wro4j I see the recipe that you linked, but this recipe is not enough due to this version is for Java11,

org.openrewrite.java.migrate.Java8toJava11
[WARNING]                             org.openrewrite.java.migrate.javax.AddJaxbDependencies
[WARNING]                                 org.openrewrite.java.dependencies.AddDependency: {groupId=jakarta.xml.bind, artifactId=jakarta.xml.bind-api, version=2.3.x, onlyIfUsing=javax.xml.bind..*, acceptTransitive=true}
[WARNING]                             org.openrewrite.java.migrate.cobertura.RemoveCoberturaMavenPlugin
[WARNING]                                 org.openrewrite.maven.RemovePlugin: {groupId=org.codehaus.mojo, artifactId=cobertura-maven-plugin}
[WARNING]                             org.openrewrite.java.migrate.wro4j.UpgradeWro4jMavenPluginVersion
[WARNING]                                 org.openrewrite.maven.UpgradePluginVersion: {groupId=ro.isdc.wro4j, artifactId=wro4j-maven-plugin, newVersion=1.10.1}

we would need to upgrade to 2.X. But anyway, it does not work (dont change the property version to 1.10.1) but I dont know why.

I just update the project with the SNAPSHOT versions if you want to try.

Thanks in advance,
Manu

@timtebeek
Copy link
Contributor

We've since done two full release trains with related fixes. Are you seeing any improvement with the latest?
https://github.com/openrewrite/rewrite-recipe-bom/releases/tag/v2.15.0

@timtebeek timtebeek added the question Further information is requested label Jul 15, 2024
@mgvinuesa
Copy link
Author

mgvinuesa commented Jul 18, 2024

Hello, sorry for the delay.

I just update the following versions:

  • rewrite-maven-plugin to 5.36.0
  • rewrite-spring to 5.15.1

The result is different from the previous report. To remember it, the main problems were two:

  • The wro4j-maven-plugin might upgrade from 1.8.0 to 2.X due to Java17 compatibility.
  • The recipe that adds jakarta.xml.bind-api must include the latest version instead of 2.3.3.

Now the changes are:

  • Regarding wro4j-maven-plugin now the version is 1.10.1 instead 1.8.0 (the original one) but not the needed one (2.x)
  • About jakarta, now the dependency is not forced to an specific version (2.3.3) and the plugin adds a new dependency management:
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>jakarta.validation</groupId>
        <artifactId>jakarta.validation-api</artifactId>
        <version>3.1.0</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

So the problem regarding jakarta is solved (i think that add the dependency management is not needed (spring does it) but it is not important). But the plugin is not solved, now the error when build the project is:

[ERROR] Failed to execute goal �[32mro.isdc.wro4j:wro4j-maven-plugin:1.10.1:run�[m �[1m(default)�[m on project �[36mspring-petclinic�[m: �[1;31mExecution default of goal ro.isdc.wro4j:wro4j-maven-plugin:1.10.1:run failed: Plugin ro.isdc.wro4j:wro4j-maven-plugin:1.10.1 or one of its dependencies could not be resolved: Failed to collect dependencies for ro.isdc.wro4j:wro4j-maven-plugin:jar:1.10.1 ()�[m: Could not resolve version conflict among [ro.isdc.wro4j:wro4j-maven-plugin:jar:1.10.1 -> ro.isdc.wro4j:wro4j-extensions:jar:1.10.1 -> org.webjars.npm:jshint:jar:2.11.0 -> org.webjars.npm:minimatch:jar:[3.0.2,3.1), ro.isdc.wro4j:wro4j-maven-plugin:jar:1.10.1 -> ro.isdc.wro4j:wro4j-extensions:jar:1.10.1 -> org.webjars.npm:jshint:jar:2.11.0 -> org.webjars.npm:cli:jar:[1.0.0,1.1) -> org.webjars.npm:glob:jar:[7.1.1,8) -> org.webjars.npm:minimatch:jar:[3.1.1,4)] -> �[1m[Help 1]�[m

It looks like a problem between some transitive dependencies for the plugin but I think that the problem is related with this version is not compatible with JDK17 ,

https://stackoverflow.com/questions/74347674/mvn-issue-with-an-old-java-codebase-clashing-dependencies
https://community.sap.com/t5/crm-and-cx-questions/wro4j-is-throwing-version-conflict-for-java-11-with-2105/qaq-p/12591404

@timtebeek
Copy link
Contributor

Thanks again! Wasn't aware there was a 2.x version of the plugin available, or that it's required for Java 17. Fixed just now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
Archived in project
Development

No branches or pull requests

2 participants