From 272b816f4b6ebff6c3f3deed1f847765bd21d196 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Fri, 20 Dec 2024 11:29:21 +0100 Subject: [PATCH] Add testRuntimeOnly for now, with TODO on Refaster classpath --- build.gradle.kts | 10 +++++----- .../java/logging/log4j/Log4j1ToLog4j2Test.java | 4 +--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 9284484..fe38fc6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,10 +20,6 @@ recipeDependencies { } dependencies { - compileOnly("log4j:log4j:1.+") { - because("log4j 1 has critical vulnerabilities but we need the type for the refaster recipe during compilation") - } - compileOnly("org.projectlombok:lombok:latest.release") annotationProcessor("org.projectlombok:lombok:latest.release") @@ -44,6 +40,11 @@ dependencies { exclude("com.google.auto.service", "auto-service-annotations") } + compileOnly("log4j:log4j:1.+") { + because("log4j 1 has critical vulnerabilities but we need the type for the refaster recipe during compilation") + } + testRuntimeOnly("log4j:log4j:1.+") // Necessary to match for now; explore alternatives for Refaster classpath in the future + testImplementation("org.junit.jupiter:junit-jupiter-api:latest.release") testImplementation("org.junit.jupiter:junit-jupiter-params:latest.release") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:latest.release") @@ -54,4 +55,3 @@ dependencies { testImplementation("org.openrewrite:rewrite-java-tck") testImplementation("org.assertj:assertj-core:latest.release") -} diff --git a/src/test/java/org/openrewrite/java/logging/log4j/Log4j1ToLog4j2Test.java b/src/test/java/org/openrewrite/java/logging/log4j/Log4j1ToLog4j2Test.java index b398bef..3ee8ccb 100644 --- a/src/test/java/org/openrewrite/java/logging/log4j/Log4j1ToLog4j2Test.java +++ b/src/test/java/org/openrewrite/java/logging/log4j/Log4j1ToLog4j2Test.java @@ -17,7 +17,6 @@ import org.junit.jupiter.api.Test; import org.openrewrite.DocumentExample; -import org.openrewrite.InMemoryExecutionContext; import org.openrewrite.Issue; import org.openrewrite.java.JavaParser; import org.openrewrite.test.RecipeSpec; @@ -35,8 +34,7 @@ class Log4j1ToLog4j2Test implements RewriteTest { @Override public void defaults(RecipeSpec spec) { spec.recipeFromResource("/META-INF/rewrite/log4j.yml", "org.openrewrite.java.logging.log4j.Log4j1ToLog4j2") - .parser(JavaParser.fromJavaVersion() - .classpathFromResources(new InMemoryExecutionContext(), "log4j-1.2")); + .parser(JavaParser.fromJavaVersion().classpath("log4j")); } @DocumentExample