When running OpenRewrite on my multi module project (Maven 3.99, Java 21) with this configuration in the root pom:
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.21.0</version>
<configuration>
<exportDatatables>true</exportDatatables>
<activeRecipes>
<recipe>org.openrewrite.java.testing.junit5.JUnit4to5Migration</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-testing-frameworks</artifactId>
<version>3.19.0</version>
</dependency>
</dependencies>
</plugin>
Then after successfully compiling the project OpenRewrite terminates with the following stack trace:
[ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:6.16.0:run (default-cli) on project locs-rest-api-client: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:6.16.0:run failed: Error while visiting model\src\test\java\de\mvbonline\locs\adb\IsbnRangeIntegrationTest.java: java.lang.IllegalArgumentException: Unable to find classpath resource dependencies beginning with: 'apiguardian-api-1.1', 'junit-jupiter-api-5'
[ERROR] org.openrewrite.java.JavaParser.dependenciesFromResources(JavaParser.java:139)
[ERROR] org.openrewrite.java.JavaParser$Builder.classpathFromResources(JavaParser.java:316)
[ERROR] org.openrewrite.java.testing.junit5.UpdateTestAnnotation$UpdateTestAnnotationVisitor.visitMethodDeclaration(UpdateTestAnnotation.java:114)
[ERROR] org.openrewrite.java.testing.junit5.UpdateTestAnnotation$UpdateTestAnnotationVisitor.visitMethodDeclaration(UpdateTestAnnotation.java:57)
[ERROR] org.openrewrite.java.tree.J$MethodDeclaration.acceptJava(J.java:4036)
[ERROR] org.openrewrite.java.tree.J.accept(J.java:60)
[ERROR] org.openrewrite.TreeVisitor.visit(TreeVisitor.java:245)
[ERROR] org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:311)
[ERROR] org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1310)
[ERROR] org.openrewrite.java.JavaVisitor.lambda$visitBlock$4(JavaVisitor.java:392)
[ERROR] org.openrewrite.internal.ListUtils.map(ListUtils.java:245)
[ERROR] org.openrewrite.internal.ListUtils.map(ListUtils.java:269)
[ERROR] org.openrewrite.java.JavaVisitor.visitBlock(JavaVisitor.java:391)
[ERROR] org.openrewrite.java.JavaIsoVisitor.visitBlock(JavaIsoVisitor.java:88)
[ERROR] org.openrewrite.java.JavaIsoVisitor.visitBlock(JavaIsoVisitor.java:30)
[ERROR] org.openrewrite.java.tree.J$Block.acceptJava(J.java:848)
[ERROR] ...
I tried to add these dependencies either to my project or to the plugin, either with scope test or not, but nothing I did changed the error message in any way.
My project does not use apiguardian, so this will be needed by the recipe?
What am I missing or doing wrong?
----- EDIT -----
This problem went away after
- upgrading the OpenRewrite plugin
- configuring IntelliJ to use @argfile to shorten the class path
- refreshing, synching and reloading the project more than once
I don't know which of these actions let the problem vanish, but it seems, it was more an issue of the IntelliJ Maven plugin.
No additions to the dependencies were necessary.
user.homeis set? The reason I ask is because those dependencies should be read from a packaged type table and written to~/.rewrite/classpath/.tt/, which~taken fromSystem.getProperty("user.home").