rewrite-maven-plugin icon indicating copy to clipboard operation
rewrite-maven-plugin copied to clipboard

Running rewrite rules gets errors in other goals if run with java 17

Open davidmichaelkarr opened this issue 1 year ago • 3 comments

I am working on a process that developers on related teams can use to convert their codebases from using Java 11 and SpringBoot 2.x to Java 17 and SpringBoot 3.x. We are trying to use openrewrite rules to convert swagger to openapi, and also to convert javax to jakarta.

Some other developers on my "platform" team assembled the following command line to do the first conversion:

mvn -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-spring:RELEASE -Drewrite.activeRecipes=org.openrewrite.openapi.swagger.SwaggerToOpenAPI,org.openrewrite.openapi.swagger.MigrateApiModelPropertyToSchema

What we find is that besides running this "run" goal, it also executes other plugins defined in the pom.xml. For instance, the build I'm testing this on uses the "org.jvnet.jaxb2.maven2:maven-jaxb2-plugin" plugin. As part of the upgrade process, we have to convert this to a different plugin, but that's defined in a later step, after we execute these openrewrite rules.

When I run this with Java 11, it does successfully execute the openrewrite rule, but it does also execute that other goal, including "compile" and "testCompile". When we run this with Java 17, we get errors with the "jaxb2" plugin, because that plugin can't be used with Java 17. If we absolutely had to, we could specify in the upgrade process that you can't install Java 17 until you complete the openrewrite rules, but that's a little awkward. Is there some way we can configure this mvn command line so that it can work with Java 17 by ONLY executing the openrewrite rules, and is it possible for the rules to succeed that way?

davidmichaelkarr avatar Jul 25 '24 20:07 davidmichaelkarr