From 24b41bb683ccbf093b60fdbe5336e44eee6c2c7b Mon Sep 17 00:00:00 2001 From: Knut Wannheden Date: Mon, 11 Nov 2024 08:13:50 +0100 Subject: [PATCH] Make Lombok support opt-in until ready While investigating and fixing a few last remaining bugs in the Lombok support, the feature requires an explicit opt-in via setting the `REWRITE_LOMBOK` environment variable or the `rewrite.lombok` system property to any non-null value. --- .../java/isolated/ReloadableJava17Parser.java | 3 ++- .../java/org/openrewrite/java/tree/LombokTest.java | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17Parser.java b/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17Parser.java index a5301b05e19..8441177d969 100644 --- a/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17Parser.java +++ b/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17Parser.java @@ -117,7 +117,8 @@ private ReloadableJava17Parser( Options.instance(context).put("-proc", "none"); LOMBOK: - if (classpath != null && classpath.stream().anyMatch(it -> it.toString().contains("lombok"))) { + if (System.getenv().getOrDefault("REWRITE_LOMBOK", System.getProperty("rewrite.lombok")) != null && + classpath != null && classpath.stream().anyMatch(it -> it.toString().contains("lombok"))) { Processor lombokProcessor = null; try { // https://projectlombok.org/contributing/lombok-execution-path diff --git a/rewrite-java-tck/src/main/java/org/openrewrite/java/tree/LombokTest.java b/rewrite-java-tck/src/main/java/org/openrewrite/java/tree/LombokTest.java index d4d02650c0a..192c592e477 100644 --- a/rewrite-java-tck/src/main/java/org/openrewrite/java/tree/LombokTest.java +++ b/rewrite-java-tck/src/main/java/org/openrewrite/java/tree/LombokTest.java @@ -15,6 +15,8 @@ */ package org.openrewrite.java.tree; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledOnJre; @@ -34,6 +36,16 @@ @EnabledOnJre(JRE.JAVA_17) class LombokTest implements RewriteTest { + @BeforeAll + static void setUp() { + System.setProperty("rewrite.lombok", "true"); + } + + @AfterAll + static void tearDown() { + System.clearProperty("rewrite.lombok"); + } + @Override public void defaults(RecipeSpec spec) { spec.parser(JavaParser.fromJavaVersion().classpath("lombok"));