Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 8 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ recipeDependencies {
parserClasspath("commons-logging:commons-logging:1.+")
parserClasspath("ch.qos.logback:logback-classic:1.3.+")
parserClasspath("org.projectlombok:lombok:1.18.+")
parserClasspath("org.jboss.logging:jboss-logging:3.+")
}

dependencies {
Expand All @@ -31,11 +32,11 @@ dependencies {
implementation("org.openrewrite.recipe:rewrite-static-analysis:${rewriteVersion}")
runtimeOnly("org.openrewrite:rewrite-java-17")

implementation("org.apache.logging.log4j:log4j-core:2.+") {
compileOnly("org.apache.logging.log4j:log4j-core:2.+") {
exclude("com.github.spotbugs", "spotbugs-annotations").because("https://github.com/apache/logging-log4j2/issues/3754")
}
implementation("org.slf4j:slf4j-api:2.+")
implementation("org.jboss.logging:jboss-logging:3.+")
compileOnly("org.slf4j:slf4j-api:2.+")
compileOnly("org.jboss.logging:jboss-logging:3.+")

annotationProcessor("org.openrewrite:rewrite-templating:$rewriteVersion")
implementation("org.openrewrite:rewrite-templating:$rewriteVersion")
Expand Down Expand Up @@ -63,3 +64,7 @@ dependencies {
testImplementation("org.assertj:assertj-core:latest.release")
testRuntimeOnly(gradleApi())
}

tasks.withType<JavaCompile> {
options.compilerArgs.add("-Arewrite.javaParserClasspathFrom=resources")
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;
import org.openrewrite.InMemoryExecutionContext;
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
Expand All @@ -35,7 +36,7 @@ public void defaults(RecipeSpec spec) {
@Test
void log4j1() {
rewriteRun(
spec -> spec.parser(JavaParser.fromJavaVersion().classpath("log4j")),
spec -> spec.parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "log4j-1+")),
//language=java
java(
"""
Expand Down Expand Up @@ -77,7 +78,7 @@ void test() {
@Test
void log4j2() {
rewriteRun(
spec -> spec.parser(JavaParser.fromJavaVersion().classpath("log4j-core", "log4j-api")),
spec -> spec.parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "log4j-core-2+", "log4j-api-2+")),
//language=java
java(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;
import org.openrewrite.InMemoryExecutionContext;
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

Expand All @@ -26,7 +28,8 @@ class ChangeLoggersToPrivateTest implements RewriteTest {

@Override
public void defaults(RecipeSpec spec) {
spec.recipe(new ChangeLoggersToPrivate());
spec.recipe(new ChangeLoggersToPrivate())
.parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "log4j-1+", "slf4j-api-2.1.+", "log4j-api-2.+"));
}

@DocumentExample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.openrewrite.DocumentExample;
import org.openrewrite.InMemoryExecutionContext;
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

Expand All @@ -27,7 +29,8 @@
class FormattedArgumentsToVMethodTest implements RewriteTest {
@Override
public void defaults(RecipeSpec spec) {
spec.recipe(new FormattedArgumentsToVMethodRecipes());
spec.recipe(new FormattedArgumentsToVMethodRecipes())
.parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "jboss-logging"));
}

@DocumentExample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;
import org.openrewrite.InMemoryExecutionContext;
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

Expand All @@ -25,10 +27,8 @@
class JBossLoggingBestPracticesTest implements RewriteTest {
@Override
public void defaults(RecipeSpec spec) {
spec.recipeFromResource(
"/META-INF/rewrite/jboss.yml",
"org.openrewrite.java.logging.jboss.JBossLoggingBestPractices"
);
spec.recipeFromResource("/META-INF/rewrite/jboss.yml", "org.openrewrite.java.logging.jboss.JBossLoggingBestPractices")
.parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "jboss-logging"));
}

@DocumentExample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.openrewrite.DocumentExample;
import org.openrewrite.InMemoryExecutionContext;
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

Expand All @@ -28,7 +30,8 @@ class LoggerLevelArgumentToMethodTest implements RewriteTest {

@Override
public void defaults(RecipeSpec spec) {
spec.recipe(new LoggerLevelArgumentToMethod());
spec.recipe(new LoggerLevelArgumentToMethod())
.parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "jboss-logging"));
}

@DocumentExample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

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 @@ -34,7 +35,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().classpath("log4j"));
.parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "log4j-1+"));
}

@DocumentExample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;
import org.openrewrite.InMemoryExecutionContext;
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
Expand All @@ -28,7 +29,7 @@ class LoggingExceptionConcatenationTest implements RewriteTest {
@Override
public void defaults(RecipeSpec spec) {
spec.recipe(new LoggingExceptionConcatenationRecipe())
.parser(JavaParser.fromJavaVersion().classpath("log4j-api"));
.parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "log4j-api"));
}

@DocumentExample
Expand All @@ -39,7 +40,7 @@ void loggingException() {
java(
"""
import org.apache.logging.log4j.Logger;

class Test {
void test(Logger logger, RuntimeException e) {
logger.error("test" + e);
Expand All @@ -48,7 +49,7 @@ void test(Logger logger, RuntimeException e) {
""",
"""
import org.apache.logging.log4j.Logger;

class Test {
void test(Logger logger, RuntimeException e) {
logger.error("test", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;
import org.openrewrite.InMemoryExecutionContext;
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
import org.openrewrite.test.SourceSpec;
Expand All @@ -31,7 +33,8 @@
class JBossLoggingToSlf4jTest implements RewriteTest {
@Override
public void defaults(RecipeSpec spec) {
spec.recipeFromResources("org.openrewrite.java.logging.slf4j.JBossLoggingToSlf4j");
spec.recipeFromResources("org.openrewrite.java.logging.slf4j.JBossLoggingToSlf4j")
.parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "jboss-logging"));
}

@DocumentExample
Expand Down
Loading