1

I am executing this mvn command on root level of my project. The project has many submodules and APIs.

 mvn -U org.openrewrite.maven:rewrite-maven-plugin:run \
  -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-migrate-java:RELEASE \
  -Drewrite.activeRecipes=org.openrewrite.java.migrate.jakarta.JavaxMigrationToJakarta

I can see in logs, as seen below, it does this rewrites for all modules. But eventually I dont see anything has changed in my codebase. Everything looks same in the end. What am I missing?

rewrite:5.2.6:run (default-cli) < compile @ my-module <<<

Ofcourse I also see the usual errors in logs

 package javax.persistence does not exist
Spring
  • 11,333
  • 29
  • 116
  • 185
  • 1
    is your project in a working state before you execute the recipe? as in can you run mvn verify and have that working? we rely on Maven to provide us with the necessary classpath entries, such that our parser can resolve the necessary types, which our matchers need before they make changes. sometimes we see people run recipes on projects that don't compile, for instance if they manually removed or swapped out dependencies. in those case you might not see recipes make the expected changes, because they can not resolve the types they need. – Tim Jul 17 '23 at 10:34
  • @Tim I have this same problem: I'm applying the Java8toJava11 recipe to a Java 8 project that correctly `mvn verify`s using jdk8. The only thing `mvn rewrite:run` does is changing the `maven.compiler.source/target` in my POM from 1.8 to 11, and one `!isPresent()` to `isEmpty()` in some submodule class (so it _does_ process submodules). With just those changes, I try to `mvn compile` the project with jdk11... and it fails because of references to `com.sun.*` packages that I expected OpenRewrite to at least detect and notify me of, if not solve. So... what can we do about it? – walen Jul 24 '23 at 11:12
  • @Tim PS: some of those `com.sun.*` references (not all of them) came from Lombok 1.16, which I have upgraded to 1.18; but this is one of those changes I expected OpenRewrite to do. I've noticed that the composite recipe for Java8toJava11 contains recipes for JaCoCo etc. version upgrades but not for Lombok. I would like to contribute to the project by creating and adding a recipe for this. Could you point me in the right direction to do this? – walen Jul 24 '23 at 11:15
  • Hi @walen We should already be upgrading Lombok as per https://github.com/openrewrite/rewrite-migrate-java/blob/53f843af6f90eedf2e305d58c2a0a2b3a4b3121a/src/main/resources/META-INF/rewrite/lombok.yml#L25-L28 , which we test in https://github.com/openrewrite/rewrite-migrate-java/blob/53f843af6f90eedf2e305d58c2a0a2b3a4b3121a/src/test/java/org/openrewrite/java/migrate/lombok/UpdateLombokToJava17Test.java#L74 – Tim Jul 24 '23 at 11:35
  • Perhaps good to log an issue if we're not making those changes for you, such that it's clear how you're running, which versions and on what type of project. – Tim Jul 24 '23 at 11:36
  • @Tim Thanks for the link, however that's for Java 17 upgrade. This is about Java 11. Is Lombok being upgraded as part of Java 11 migration too? I can see the `UpdateLombokToJava17` recipe in the list of recipes composing `UpgradeToJava17`, but not a trace of Lombok in `Java8toJava11`. – walen Jul 24 '23 at 11:43
  • @Tim In any case, as I mentioned (and in line with OP's question), the Java 11 migration definitely doesn't work. This is a very small project I'm migrating, but it has REST endpoints, event listeners, JSON (de)serializing etc. -- OpenRewrite should be changing dependencies and imports left and right, but for some reason it doesn't. – walen Jul 24 '23 at 11:50
  • 1
    Probably best to log two issues, or reach out via our Slack, as the comment section here is quite limited in what we can share and resolve. Happy to help you along there! – Tim Jul 24 '23 at 11:52
  • Here's a PR to also upgrade Lombok for Java 11: https://github.com/openrewrite/rewrite-migrate-java/pull/265 – Tim Jul 24 '23 at 12:04
  • 1
    Thanks for bringing this to our attention! – Tim Jul 24 '23 at 12:05
  • PR merged and will go into the next release; that ought to fix the issue. Feel free to try our snapshot versions to see if that resolves the issue for you: https://docs.openrewrite.org/reference/snapshot-instructions – Tim Jul 27 '23 at 08:28

0 Answers0