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

JodaTime should pull threeten-extra from resources, not classpath #676

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).<J>map(t -> t.apply(
return VarTemplates.getTemplate(multiVariable, ctx).<J>map(t -> t.apply(
updateCursor(m),
m.getCoordinates().replace(),
VarTemplates.getTemplateArgs(m))).orElse(multiVariable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -40,7 +41,7 @@ public class VarTemplates {
}
};

public static Optional<JavaTemplate> getTemplate(J.VariableDeclarations variable) {
public static Optional<JavaTemplate> getTemplate(J.VariableDeclarations variable, ExecutionContext ctx) {
JavaType.Class type = (JavaType.Class) variable.getTypeExpression().getType();
String typeName = JodaToJavaTimeType.get(type.getFullyQualifiedName());
if (typeName == null) {
Expand Down Expand Up @@ -68,7 +69,7 @@ public static Optional<JavaTemplate> 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());
}

Expand Down
Binary file modified src/main/resources/META-INF/rewrite/classpath.tsv.zip
Binary file not shown.
Loading