Skip to content

Commit

Permalink
Remove log4j from runtime classpath as it is only needed to generate …
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
pstreef and timtebeek authored Dec 20, 2024
1 parent 8dc20c7 commit 8bf0aa2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ dependencies {
implementation("org.openrewrite.recipe:rewrite-static-analysis:${rewriteVersion}")
runtimeOnly("org.openrewrite:rewrite-java-17")

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

Expand All @@ -41,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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 8bf0aa2

Please sign in to comment.