diff --git a/build.gradle.kts b/build.gradle.kts index adfb0b3d0e..e41828c493 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,6 +10,7 @@ recipeDependencies { parserClasspath("javax.persistence:javax.persistence-api:2.2") parserClasspath("jakarta.enterprise:jakarta.enterprise.cdi-api:3.0.0-M4") parserClasspath("org.glassfish:javax.servlet:3.0") + parserClasspath("org.threeten:threeten-extra:1.8.0") } val rewriteVersion = rewriteRecipe.rewriteVersion.get() diff --git a/src/main/java/org/openrewrite/java/migrate/joda/JodaTimeVisitor.java b/src/main/java/org/openrewrite/java/migrate/joda/JodaTimeVisitor.java index dade75830c..2a28205e4d 100644 --- a/src/main/java/org/openrewrite/java/migrate/joda/JodaTimeVisitor.java +++ b/src/main/java/org/openrewrite/java/migrate/joda/JodaTimeVisitor.java @@ -112,7 +112,7 @@ public Javadoc visitReference(Javadoc.Reference reference, ExecutionContext ctx) return multiVariable; } J.VariableDeclarations m = (J.VariableDeclarations) super.visitVariableDeclarations(multiVariable, ctx); - return VarTemplates.getTemplate(multiVariable).map(t -> t.apply( + return VarTemplates.getTemplate(multiVariable, ctx).map(t -> t.apply( updateCursor(m), m.getCoordinates().replace(), VarTemplates.getTemplateArgs(m))).orElse(multiVariable); diff --git a/src/main/java/org/openrewrite/java/migrate/joda/templates/VarTemplates.java b/src/main/java/org/openrewrite/java/migrate/joda/templates/VarTemplates.java index 0b5968beeb..f6afa0ba29 100644 --- a/src/main/java/org/openrewrite/java/migrate/joda/templates/VarTemplates.java +++ b/src/main/java/org/openrewrite/java/migrate/joda/templates/VarTemplates.java @@ -15,6 +15,7 @@ */ package org.openrewrite.java.migrate.joda.templates; +import org.openrewrite.ExecutionContext; import org.openrewrite.java.JavaParser; import org.openrewrite.java.JavaTemplate; import org.openrewrite.java.tree.J; @@ -40,7 +41,7 @@ public class VarTemplates { } }; - public static Optional getTemplate(J.VariableDeclarations variable) { + public static Optional getTemplate(J.VariableDeclarations variable, ExecutionContext ctx) { JavaType.Class type = (JavaType.Class) variable.getTypeExpression().getType(); String typeName = JodaToJavaTimeType.get(type.getFullyQualifiedName()); if (typeName == null) { @@ -68,7 +69,7 @@ public static Optional getTemplate(J.VariableDeclarations variable } return Optional.of(JavaTemplate.builder(template.toString()) .imports(typeName) - .javaParser(JavaParser.fromJavaVersion().classpath("threeten-extra")) + .javaParser(JavaParser.fromJavaVersion().classpathFromResources(ctx, "threeten-extra")) .build()); } diff --git a/src/main/resources/META-INF/rewrite/classpath.tsv.zip b/src/main/resources/META-INF/rewrite/classpath.tsv.zip index fa888b0f12..d248b93fba 100644 Binary files a/src/main/resources/META-INF/rewrite/classpath.tsv.zip and b/src/main/resources/META-INF/rewrite/classpath.tsv.zip differ