Skip to content

Commit 8bf0aa2

Browse files
pstreeftimtebeek
andauthored
Remove log4j from runtime classpath as it is only needed to generate a recipe from a refaster template (#204)
* Remove log4j from runtime classpath as it is only needed to generate a recipe from a refaster template This does not yet work as expected in the test * Add testRuntimeOnly for now, with TODO on Refaster classpath * Add missing trailing brace --------- Co-authored-by: Tim te Beek <[email protected]>
1 parent 8dc20c7 commit 8bf0aa2

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ dependencies {
3131
implementation("org.openrewrite.recipe:rewrite-static-analysis:${rewriteVersion}")
3232
runtimeOnly("org.openrewrite:rewrite-java-17")
3333

34-
implementation("log4j:log4j:1.+")
3534
implementation("org.apache.logging.log4j:log4j-core:2.+")
3635
implementation("org.slf4j:slf4j-api:2.+")
3736

@@ -41,6 +40,11 @@ dependencies {
4140
exclude("com.google.auto.service", "auto-service-annotations")
4241
}
4342

43+
compileOnly("log4j:log4j:1.+") {
44+
because("log4j 1 has critical vulnerabilities but we need the type for the refaster recipe during compilation")
45+
}
46+
testRuntimeOnly("log4j:log4j:1.+") // Necessary to match for now; explore alternatives for Refaster classpath in the future
47+
4448
testImplementation("org.junit.jupiter:junit-jupiter-api:latest.release")
4549
testImplementation("org.junit.jupiter:junit-jupiter-params:latest.release")
4650
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:latest.release")

src/test/java/org/openrewrite/java/logging/log4j/Log4j1ToLog4j2Test.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import org.junit.jupiter.api.Test;
1919
import org.openrewrite.DocumentExample;
20-
import org.openrewrite.InMemoryExecutionContext;
2120
import org.openrewrite.Issue;
2221
import org.openrewrite.java.JavaParser;
2322
import org.openrewrite.test.RecipeSpec;
@@ -35,8 +34,7 @@ class Log4j1ToLog4j2Test implements RewriteTest {
3534
@Override
3635
public void defaults(RecipeSpec spec) {
3736
spec.recipeFromResource("/META-INF/rewrite/log4j.yml", "org.openrewrite.java.logging.log4j.Log4j1ToLog4j2")
38-
.parser(JavaParser.fromJavaVersion()
39-
.classpathFromResources(new InMemoryExecutionContext(), "log4j-1.2"));
37+
.parser(JavaParser.fromJavaVersion().classpath("log4j"));
4038
}
4139

4240
@DocumentExample

0 commit comments

Comments
 (0)