From 74045168f5c30bf3dd056dd55bb9c1d2e6228f66 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Fri, 15 Dec 2023 00:46:31 +0100 Subject: [PATCH 01/23] Always show color in Maven output --- .mvn/maven.config | 1 + 1 file changed, 1 insertion(+) diff --git a/.mvn/maven.config b/.mvn/maven.config index 7dd0bf2283..282d58718f 100644 --- a/.mvn/maven.config +++ b/.mvn/maven.config @@ -1,3 +1,4 @@ --batch-mode --errors --strict-checksums +-Dstyle.color=always \ No newline at end of file From 54db453e6ac0b7a26edcbaca5170e5efa25e0742 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Fri, 15 Dec 2023 00:47:38 +0100 Subject: [PATCH 02/23] Add rewrite-templating as annotation processor --- error-prone-contrib/pom.xml | 21 +++++++++++++++++---- pom.xml | 6 ++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/error-prone-contrib/pom.xml b/error-prone-contrib/pom.xml index f268bbeab3..c4f55790cb 100644 --- a/error-prone-contrib/pom.xml +++ b/error-prone-contrib/pom.xml @@ -77,10 +77,6 @@ auto-value-annotations provided - - com.google.googlejavaformat - google-java-format - com.google.guava guava @@ -181,6 +177,11 @@ mongodb-driver-core test + + org.openrewrite + rewrite-java + provided + org.reactivestreams reactive-streams @@ -246,12 +247,24 @@ refaster-support ${project.version} + + org.openrewrite + rewrite-templating + LATEST + -Xplugin:RefasterRuleCompiler -Xplugin:DocumentationGenerator -XoutputDirectory=${project.build.directory}/docs + + + org.openrewrite + rewrite-java + ${version.rewrite} + + diff --git a/pom.xml b/pom.xml index 60adb227ad..fb9884836c 100644 --- a/pom.xml +++ b/pom.xml @@ -214,6 +214,7 @@ 1.0.1 0.10.18 1.1.4 + 8.11.2 3.2.3 @@ -455,6 +456,11 @@ + + org.openrewrite + rewrite-java + ${version.rewrite} + org.slf4j slf4j-bom From c09efe0f146b1abf09b18965bbaf5a5152fee4eb Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sat, 16 Dec 2023 14:19:05 +0100 Subject: [PATCH 03/23] Verify generated `StringRulesRecipes` work --- error-prone-contrib/pom.xml | 33 ++++++++++++----- .../refasterrules/StringRulesRecipesTest.java | 35 +++++++++++++++++++ pom.xml | 9 +++-- 3 files changed, 66 insertions(+), 11 deletions(-) create mode 100644 error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/StringRulesRecipesTest.java diff --git a/error-prone-contrib/pom.xml b/error-prone-contrib/pom.xml index c4f55790cb..6c48e5c1f4 100644 --- a/error-prone-contrib/pom.xml +++ b/error-prone-contrib/pom.xml @@ -77,6 +77,10 @@ auto-value-annotations provided + + com.google.googlejavaformat + google-java-format + com.google.guava guava @@ -182,6 +186,26 @@ rewrite-java provided + + org.openrewrite + rewrite-java-11 + provided + + + org.openrewrite + rewrite-java + provided + + + org.openrewrite + rewrite-templating + provided + + + org.openrewrite + rewrite-test + test + org.reactivestreams reactive-streams @@ -250,7 +274,7 @@ org.openrewrite rewrite-templating - LATEST + ${version.rewrite-templating} @@ -258,13 +282,6 @@ -Xplugin:DocumentationGenerator -XoutputDirectory=${project.build.directory}/docs - - - org.openrewrite - rewrite-java - ${version.rewrite} - - diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/StringRulesRecipesTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/StringRulesRecipesTest.java new file mode 100644 index 0000000000..67d2282fb9 --- /dev/null +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/StringRulesRecipesTest.java @@ -0,0 +1,35 @@ +package tech.picnic.errorprone.refasterrules; + +import org.junit.jupiter.api.Test; +import org.openrewrite.test.RecipeSpec; +import org.openrewrite.test.RewriteTest; + +import static org.openrewrite.java.Assertions.java; + +class StringRulesRecipesTest implements RewriteTest { + + @Override + public void defaults(RecipeSpec spec) { + spec.recipe(new StringRulesRecipes()); + } + + @Test + void stringValueOf() { + rewriteRun( + //language=java + java( + "import java.util.Objects;\n" + + "class Test {\n" + + " String test(Object object) {\n" + + " return Objects.toString(object);\n" + + " }\n" + + "}", + "class Test {\n" + + " String test(Object object) {\n" + + " return String.valueOf(object);\n" + + " }\n" + + "}" + ) + ); + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index fb9884836c..6c2c7529c8 100644 --- a/pom.xml +++ b/pom.xml @@ -215,6 +215,7 @@ 0.10.18 1.1.4 8.11.2 + 1.4.0-SNAPSHOT 3.2.3 @@ -457,9 +458,11 @@ - org.openrewrite - rewrite-java - ${version.rewrite} + org.openrewrite.recipe + rewrite-recipe-bom + 2.5.3 + pom + import org.slf4j From e556b3f41dfa1b23df36d6377cddc489c91f8fd5 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sat, 16 Dec 2023 14:23:42 +0100 Subject: [PATCH 04/23] Drop unused `version.rewrite` --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6c2c7529c8..851c3fd576 100644 --- a/pom.xml +++ b/pom.xml @@ -214,7 +214,6 @@ 1.0.1 0.10.18 1.1.4 - 8.11.2 1.4.0-SNAPSHOT 3.2.3 From 578f37d24aac70737f352fb03a821e45ba224539 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sat, 16 Dec 2023 22:35:28 +0100 Subject: [PATCH 05/23] Use rewrite-templating v1.3.9 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 851c3fd576..e3a1a082e3 100644 --- a/pom.xml +++ b/pom.xml @@ -214,7 +214,7 @@ 1.0.1 0.10.18 1.1.4 - 1.4.0-SNAPSHOT + 1.3.9 3.2.3 From 27ba49ff3f319f1243a142776ba14afee17b005b Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sat, 16 Dec 2023 23:29:41 +0100 Subject: [PATCH 06/23] Declare used dependency --- error-prone-contrib/pom.xml | 6 +++--- pom.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/error-prone-contrib/pom.xml b/error-prone-contrib/pom.xml index 6c48e5c1f4..960322c149 100644 --- a/error-prone-contrib/pom.xml +++ b/error-prone-contrib/pom.xml @@ -183,17 +183,17 @@ org.openrewrite - rewrite-java + rewrite-core provided org.openrewrite - rewrite-java-11 + rewrite-java provided org.openrewrite - rewrite-java + rewrite-java-11 provided diff --git a/pom.xml b/pom.xml index e3a1a082e3..851c3fd576 100644 --- a/pom.xml +++ b/pom.xml @@ -214,7 +214,7 @@ 1.0.1 0.10.18 1.1.4 - 1.3.9 + 1.4.0-SNAPSHOT 3.2.3 From 4763cd3804de17aaf365746cb09c6c204ea2bf2f Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sun, 17 Dec 2023 14:59:11 +0100 Subject: [PATCH 07/23] Adopt rewrite-templating 1.3.11 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 851c3fd576..160e75bca9 100644 --- a/pom.xml +++ b/pom.xml @@ -214,7 +214,7 @@ 1.0.1 0.10.18 1.1.4 - 1.4.0-SNAPSHOT + 1.3.11 3.2.3 From a80d2597650318e96ad79142d3dfb163f2616b2c Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sun, 17 Dec 2023 15:05:31 +0100 Subject: [PATCH 08/23] Apply formatter to StringRulesRecipesTest --- .../refasterrules/StringRulesRecipesTest.java | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/StringRulesRecipesTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/StringRulesRecipesTest.java index 67d2282fb9..777f45be53 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/StringRulesRecipesTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/StringRulesRecipesTest.java @@ -1,35 +1,33 @@ package tech.picnic.errorprone.refasterrules; +import static org.openrewrite.java.Assertions.java; + import org.junit.jupiter.api.Test; import org.openrewrite.test.RecipeSpec; import org.openrewrite.test.RewriteTest; -import static org.openrewrite.java.Assertions.java; - class StringRulesRecipesTest implements RewriteTest { - @Override - public void defaults(RecipeSpec spec) { - spec.recipe(new StringRulesRecipes()); - } + @Override + public void defaults(RecipeSpec spec) { + spec.recipe(new StringRulesRecipes()); + } - @Test - void stringValueOf() { - rewriteRun( - //language=java - java( - "import java.util.Objects;\n" + - "class Test {\n" + - " String test(Object object) {\n" + - " return Objects.toString(object);\n" + - " }\n" + - "}", - "class Test {\n" + - " String test(Object object) {\n" + - " return String.valueOf(object);\n" + - " }\n" + - "}" - ) - ); - } -} \ No newline at end of file + @Test + void stringValueOf() { + rewriteRun( + // language=java + java( + "import java.util.Objects;\n" + + "class Test {\n" + + " String test(Object object) {\n" + + " return Objects.toString(object);\n" + + " }\n" + + "}", + "class Test {\n" + + " String test(Object object) {\n" + + " return String.valueOf(object);\n" + + " }\n" + + "}")); + } +} From ef9771ae206a43d3310cc49df3355ef211341453 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sun, 17 Dec 2023 16:07:11 +0100 Subject: [PATCH 09/23] Add a test that reuses StringRulesTestInput & Output --- .../refasterrules/StringRulesRecipesTest.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/StringRulesRecipesTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/StringRulesRecipesTest.java index 777f45be53..3405a1a877 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/StringRulesRecipesTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/refasterrules/StringRulesRecipesTest.java @@ -2,7 +2,12 @@ import static org.openrewrite.java.Assertions.java; +import com.google.errorprone.FileObjects; +import java.io.IOException; +import javax.tools.JavaFileObject; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.openrewrite.java.JavaParser; import org.openrewrite.test.RecipeSpec; import org.openrewrite.test.RewriteTest; @@ -17,7 +22,7 @@ public void defaults(RecipeSpec spec) { void stringValueOf() { rewriteRun( // language=java - java( + java( // This would be much better with text blocks "import java.util.Objects;\n" + "class Test {\n" + " String test(Object object) {\n" @@ -30,4 +35,16 @@ void stringValueOf() { + " }\n" + "}")); } + + @Test + @Disabled("Not all rules are currently supported") + void reuseStringRulesTestInputOutput() throws IOException { + String rule = "StringRules"; + JavaFileObject before = FileObjects.forResource(getClass(), rule + "TestInput.java"); + JavaFileObject after = FileObjects.forResource(getClass(), rule + "TestOutput.java"); + rewriteRun( + spec -> + spec.parser(JavaParser.fromJavaVersion().classpath("guava", "refaster-test-support")), + java(before.getCharContent(true).toString(), after.getCharContent(true).toString())); + } } From 6583807e7b7f88f87c652862acfbfeab674f3d2b Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sun, 17 Dec 2023 18:04:56 +0100 Subject: [PATCH 10/23] Resolve license warnings --- pom.xml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 160e75bca9..06a49b413c 100644 --- a/pom.xml +++ b/pom.xml @@ -1218,12 +1218,14 @@ non-distributed (i.e. Picnic-internal) deployable artifacts (i.e. web services). --> Apache-2.0 + BSD-2-Clause BSD-3-Clause CC0-1.0 CDDL-1.1 EPL-1.0 EPL-2.0 GPL-2.0-with-classpath-exception + ICU LGPL-3.0+ MIT MIT-0 @@ -1246,10 +1248,20 @@ | The Apache Software License, Version 2.0 - + + BSD-2-Clause + | The BSD License + + + BSD-3-Clause | 3-Clause BSD License | BSD 3-clause + | BSD 3-Clause "New" or "Revised" License (BSD-3-Clause) + + | BSD licence | BSD License 3 | Eclipse Distribution License (New BSD License) | New BSD License @@ -1258,6 +1270,7 @@ CC0-1.0 | CC0 + | Public Domain, per Creative Commons CC0 @@ -1277,6 +1290,11 @@ | Eclipse Public License - v 2.0 | Eclipse Public License v2.0 + + + ICU + | Unicode/ICU License + GPL-2.0-with-classpath-exception @@ -1286,7 +1304,8 @@ | GPL2 w/ CPE - + LGPL-3.0+ | GNU Lesser Public License @@ -1296,6 +1315,7 @@ | MIT license | MIT License | The MIT License + | The MIT License (MIT) + + org.openrewrite + rewrite-templating + ${version.rewrite-templating} + org.openrewrite.recipe rewrite-recipe-bom @@ -943,6 +950,11 @@ mockito-errorprone ${version.mockito} + + org.openrewrite + rewrite-templating + ${version.rewrite-templating} + --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED diff --git a/refaster-runner/pom.xml b/refaster-runner/pom.xml index 78d7c95e8e..eb70ecc98c 100644 --- a/refaster-runner/pom.xml +++ b/refaster-runner/pom.xml @@ -87,6 +87,21 @@ junit-jupiter-params test + + org.openrewrite + rewrite-core + test + + + org.openrewrite + rewrite-java + test + + + org.openrewrite + rewrite-templating + test + diff --git a/refaster-test-support/pom.xml b/refaster-test-support/pom.xml index ddfba52718..03d91062a6 100644 --- a/refaster-test-support/pom.xml +++ b/refaster-test-support/pom.xml @@ -69,6 +69,21 @@ junit-jupiter-params test + + org.openrewrite + rewrite-core + test + + + org.openrewrite + rewrite-java + test + + + org.openrewrite + rewrite-templating + test + From 7cca5a28bc90fee38f990123ec3694a91769cf3b Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Mon, 18 Dec 2023 08:23:03 +0100 Subject: [PATCH 14/23] Prevent some noisy license plugin output --- pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pom.xml b/pom.xml index 59d3a13793..f209c8fd92 100644 --- a/pom.xml +++ b/pom.xml @@ -1238,6 +1238,7 @@ EPL-2.0 GPL-2.0-with-classpath-exception ICU + LGPL-2.1+ LGPL-3.0+ MIT MIT-0 @@ -1301,6 +1302,7 @@ EPL-2.0 | Eclipse Public License - v 2.0 | Eclipse Public License v2.0 + | EPL 2.0 @@ -1315,6 +1317,11 @@ | GNU General Public License, version 2, with the Classpath Exception | GPL2 w/ CPE + + + LGPL-2.1+ + | LGPL-2.1-or-later + From 69841efb7f9df8cb2eeab379ed7a918fcb4d299f Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Mon, 18 Dec 2023 08:44:10 +0100 Subject: [PATCH 15/23] TEST: Check whether only Windows builds break --- .github/workflows/build.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1cf9ef8f11..151a70d2f6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,10 +18,6 @@ jobs: jdk: 17.0.8 distribution: temurin experimental: false - - os: windows-2022 - jdk: 17.0.8 - distribution: temurin - experimental: false runs-on: ${{ matrix.os }} continue-on-error: ${{ matrix.experimental }} steps: From b0b759c2412afe760f29ead464fe21b5c36893ad Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Mon, 18 Dec 2023 08:56:34 +0100 Subject: [PATCH 16/23] Revert "TEST: Check whether only Windows builds break" This reverts commit d4866cfe7d0386f4fbae7b5b30d8c8115f96cf25. --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 151a70d2f6..1cf9ef8f11 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,6 +18,10 @@ jobs: jdk: 17.0.8 distribution: temurin experimental: false + - os: windows-2022 + jdk: 17.0.8 + distribution: temurin + experimental: false runs-on: ${{ matrix.os }} continue-on-error: ${{ matrix.experimental }} steps: From bb46973cd7579e051550a0ee774d226edbf93f0a Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Mon, 18 Dec 2023 09:08:19 +0100 Subject: [PATCH 17/23] TEST: Try to understand the constructed regex --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1cf9ef8f11..fa96f087ac 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,6 +42,10 @@ jobs: cache: maven - name: Display build environment details run: mvn --version + - name: "TEST: Debug 1" + run: mvn -N help:effective-pom + - name: "TEST: Debug 2" + run: mvn com.github.ekryd.echo-maven-plugin:echo-maven-plugin:2.0.0:echo -Decho.message='\Q${project.build.directory}${file.separator}\E.*' - name: Build project against vanilla Error Prone, compile Javadoc run: mvn -T1C install javadoc:jar - name: Build project with self-check against Error Prone fork From d058310e32501f9453c4411121e9e4b8e16ae95b Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Mon, 18 Dec 2023 09:41:47 +0100 Subject: [PATCH 18/23] TEST Check regex of failing module --- .github/workflows/build.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fa96f087ac..927a4130f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,10 +42,8 @@ jobs: cache: maven - name: Display build environment details run: mvn --version - - name: "TEST: Debug 1" - run: mvn -N help:effective-pom - - name: "TEST: Debug 2" - run: mvn com.github.ekryd.echo-maven-plugin:echo-maven-plugin:2.0.0:echo -Decho.message='\Q${project.build.directory}${file.separator}\E.*' + - name: "TEST: Debug" + run: mvn help:effective-pom -pl :refaster-runner - name: Build project against vanilla Error Prone, compile Javadoc run: mvn -T1C install javadoc:jar - name: Build project with self-check against Error Prone fork From 7c65fea015c765cf6716b1e8b8b59a4456be921b Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Mon, 18 Dec 2023 18:47:51 +0100 Subject: [PATCH 19/23] Test with some heuristics --- pom.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f209c8fd92..393f9c8e8b 100644 --- a/pom.xml +++ b/pom.xml @@ -1788,7 +1788,13 @@ avoid that, so we simply tell Error Prone not to warn about generated code. --> -XepDisableWarningsInGeneratedCode - -XepExcludedPaths:\Q${project.build.directory}${file.separator}\E.* + + -XepExcludedPaths:.*/\Q${project.artifactId}\E/target/.* -Xep:AndroidJdkLibsChecker:OFF - -XepExcludedPaths:.*/\Q${project.artifactId}\E/target/.* + -XepExcludedPaths:(?!.*/src/[^/]+/java/.*).* -Xep:AndroidJdkLibsChecker:OFF