Skip to content

Commit

Permalink
Make Lombok support opt-in until ready
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
knutwannheden committed Nov 11, 2024
1 parent 6b7d843 commit 24b41bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"));
Expand Down

0 comments on commit 24b41bb

Please sign in to comment.