Skip to content

Commit 7e0af0e

Browse files
author
Vincent Potucek
committed
[rewrite] Add junitbuild.rewrite-conventions.gradle.kts
Signed-off-by: Vincent Potucek <[email protected]>
1 parent 786aa07 commit 7e0af0e

File tree

11 files changed

+150
-46
lines changed

11 files changed

+150
-46
lines changed

.github/workflows/sanity-check.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: "Sanity Check"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- 'releases/**'
8+
pull_request:
9+
# The branches below must be a subset of the branches above
10+
branches:
11+
- main
12+
- 'releases/**'
13+
schedule:
14+
- cron: '0 19 * * 3'
15+
16+
concurrency:
17+
# Cancels in-progress runs only for pull requests
18+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
19+
cancel-in-progress: true
20+
21+
permissions: {}
22+
23+
env:
24+
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
25+
26+
jobs:
27+
analyze:
28+
name: Analyze (${{ matrix.language }})
29+
runs-on: ubuntu-latest
30+
permissions:
31+
security-events: write
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
include:
36+
- language: actions
37+
build-mode: none
38+
- language: java-kotlin
39+
build-mode: manual
40+
steps:
41+
- name: Check out repository
42+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
43+
with:
44+
persist-credentials: false
45+
- name: Sanity Check
46+
if: matrix.build-mode == 'manual'
47+
uses: ./.github/actions/run-gradle
48+
with:
49+
encryptionKey: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
50+
arguments: rewriteDryRun
51+
# arguments: rewriteDryRun -Dorg.gradle.jvmargs=-Xmx8G

gradle/libs.versions.toml

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[versions]
22
ant = "1.10.15"
33
apiguardian = "1.1.2"
4-
asciidoctorj-pdf = "2.3.23"
54
asciidoctor-plugins = "4.0.5" # Check if workaround in documentation.gradle.kts can be removed when upgrading
5+
asciidoctorj-pdf = "2.3.23"
66
assertj = "3.27.6"
77
bnd = "7.1.0"
88
checkstyle = "12.1.1"
@@ -15,8 +15,14 @@ junit4 = "4.13.2"
1515
junit4Min = "4.12"
1616
ktlint = "1.7.1"
1717
log4j = "2.25.2"
18-
opentest4j = "1.3.0"
1918
openTestReporting = "0.2.5"
19+
opentest4j = "1.3.0"
20+
rewrite-java-security = "7.21.0"
21+
rewrite-migrate-java = "7.21.0"
22+
rewrite-recipe-bom = "7.21.0"
23+
rewrite-rewrite = "7.21.0"
24+
rewrite-static-analysis = "7.21.0"
25+
rewrite-third-party = "7.21.0"
2026
snapshotTests = "1.11.0"
2127
surefire = "3.5.4"
2228
xmlunit = "2.11.0"
@@ -27,11 +33,13 @@ ant-junit = { module = "org.apache.ant:ant-junit", version.ref = "ant" }
2733
ant-junitlauncher = { module = "org.apache.ant:ant-junitlauncher", version.ref = "ant" }
2834
apiguardian = { module = "org.apiguardian:apiguardian-api", version.ref = "apiguardian" }
2935
archunit = { module = "com.tngtech.archunit:archunit-junit5", version = "1.4.1" }
36+
asciidoctorj-pdf = { module = "org.asciidoctor:asciidoctorj-pdf", version.ref = "asciidoctorj-pdf" } # Only declared here so Dependabot knows when to update the referenced versions
3037
assertj = { module = "org.assertj:assertj-core", version.ref = "assertj" }
3138
bndlib = { module = "biz.aQute.bnd:biz.aQute.bndlib", version.ref = "bnd" }
3239
checkstyle = { module = "com.puppycrawl.tools:checkstyle", version.ref = "checkstyle" }
3340
classgraph = { module = "io.github.classgraph:classgraph", version = "4.8.184" }
3441
commons-io = { module = "commons-io:commons-io", version = "2.21.0" }
42+
eclipse-platform = { module = "org.eclipse.platform:org.eclipse.platform", version.ref = "eclipse" }
3543
error-prone-contrib = { module = "tech.picnic.error-prone-support:error-prone-contrib", version = "0.26.0" }
3644
error-prone-core = { module = "com.google.errorprone:error_prone_core", version = "2.44.0" }
3745
fastcsv = { module = "de.siegmar:fastcsv", version = "4.1.0" }
@@ -40,17 +48,22 @@ groovy2-bom = { module = "org.codehaus.groovy:groovy-bom", version = "2.5.23" }
4048
hamcrest = { module = "org.hamcrest:hamcrest", version = "3.0" }
4149
jackson-dataformat-yaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml", version.ref = "jackson" }
4250
jackson-module-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson" }
51+
jacoco = { module = "org.jacoco:jacoco", version.ref = "jacoco" }
4352
jaxb-api = { module = "jakarta.xml.bind:jakarta.xml.bind-api", version = "4.0.4" }
4453
jaxb-runtime = { module = "org.glassfish.jaxb:jaxb-runtime", version = "4.0.6" }
4554
jfrunit = { module = "org.moditect.jfrunit:jfrunit-core", version = "1.0.0.Alpha2" }
4655
jimfs = { module = "com.google.jimfs:jimfs", version = "1.3.1" }
4756
jmh-core = { module = "org.openjdk.jmh:jmh-core", version.ref = "jmh" }
4857
jmh-generator-annprocess = { module = "org.openjdk.jmh:jmh-generator-annprocess", version.ref = "jmh" }
4958
joox = { module = "org.jooq:joox", version = "2.0.1" }
59+
jruby = { module = "org.jruby:jruby", version.ref = "jruby" }
5060
jspecify = { module = "org.jspecify:jspecify", version = "1.0.0" }
5161
jte = { module = "gg.jte:jte", version = "3.2.1" }
5262
junit4 = { module = "junit:junit", version = { require = "[4.12,)", prefer = "4.13.2" } }
63+
junit4-bundle = { module = "org.apache.servicemix.bundles:org.apache.servicemix.bundles.junit", version = "4.13.2_1" }
64+
junit4-latest = { module = "junit:junit", version.ref = "junit4" }
5365
kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.10.2" }
66+
ktlint-cli = { module = "com.pinterest.ktlint:ktlint-cli", version.ref = "ktlint" }
5467
log4j-core = { module = "org.apache.logging.log4j:log4j-core", version.ref = "log4j" }
5568
log4j-jul = { module = "org.apache.logging.log4j:log4j-jul", version.ref = "log4j" }
5669
maven = { module = "org.apache.maven:apache-maven", version = "3.9.11" }
@@ -61,31 +74,28 @@ mockito-core = { module = "org.mockito:mockito-core" }
6174
mockito-junit-jupiter = { module = "org.mockito:mockito-junit-jupiter" }
6275
nohttp-checkstyle = { module = "io.spring.nohttp:nohttp-checkstyle", version = "0.0.11" }
6376
nullaway = { module = "com.uber.nullaway:nullaway", version = "0.12.12" }
64-
opentest4j = { module = "org.opentest4j:opentest4j", version.ref = "opentest4j" }
6577
openTestReporting-cli = { module = "org.opentest4j.reporting:open-test-reporting-cli", version.ref = "openTestReporting" }
6678
openTestReporting-events = { module = "org.opentest4j.reporting:open-test-reporting-events", version.ref = "openTestReporting" }
6779
openTestReporting-tooling-core = { module = "org.opentest4j.reporting:open-test-reporting-tooling-core", version.ref = "openTestReporting" }
6880
openTestReporting-tooling-spi = { module = "org.opentest4j.reporting:open-test-reporting-tooling-spi", version.ref = "openTestReporting" }
81+
opentest4j = { module = "org.opentest4j:opentest4j", version.ref = "opentest4j" }
6982
picocli = { module = "info.picocli:picocli", version = "4.7.7" }
83+
rewrite-java-security = { module = "org.openrewrite.recipe:rewrite-java-security", version.ref = "rewrite-java-security" }
84+
rewrite-migrate-java = { module = "org.openrewrite.recipe:rewrite-migrate-java", version.ref = "rewrite-migrate-java" }
85+
rewrite-recipe-bom = { module = "org.openrewrite.recipe:rewrite-recipe-bom", version.ref = "rewrite-recipe-bom" }
86+
rewrite-rewrite = { module = "org.openrewrite.recipe:rewrite-rewrite", version.ref = "rewrite-rewrite" }
87+
rewrite-static-analysis = { module = "org.openrewrite.recipe:rewrite-static-analysis", version.ref = "rewrite-static-analysis" }
88+
rewrite-third-party = { module = "org.openrewrite.recipe:rewrite-third-party", version.ref = "rewrite-third-party" }
7089
roseau-cli = { module = "io.github.alien-tools:roseau-cli", version = "0.4.0" }
7190
slf4j-julBinding = { module = "org.slf4j:slf4j-jdk14", version = "2.0.17" }
7291
snapshotTests-junit5 = { module = "de.skuzzle.test:snapshot-tests-junit5", version.ref = "snapshotTests" }
7392
snapshotTests-xml = { module = "de.skuzzle.test:snapshot-tests-xml", version.ref = "snapshotTests" }
7493
spock1 = { module = "org.spockframework:spock-core", version = "1.3-groovy-2.5" }
75-
xmlunit-assertj = { module = "org.xmlunit:xmlunit-assertj3", version.ref = "xmlunit" }
76-
xmlunit-placeholders = { module = "org.xmlunit:xmlunit-placeholders", version.ref = "xmlunit" }
77-
xmlunit-jakarta-jaxb-impl = { module = "org.xmlunit:xmlunit-jakarta-jaxb-impl", version.ref = "xmlunit" }
7894
testingAnnotations = { module = "com.gradle:develocity-testing-annotations", version = "2.0.1" }
7995
woodstox = { module = "com.fasterxml.woodstox:woodstox-core", version = "7.1.1" }
80-
81-
# Only declared here so Dependabot knows when to update the referenced versions
82-
asciidoctorj-pdf = { module = "org.asciidoctor:asciidoctorj-pdf", version.ref = "asciidoctorj-pdf" }
83-
eclipse-platform = { module = "org.eclipse.platform:org.eclipse.platform", version.ref = "eclipse" }
84-
jacoco = { module = "org.jacoco:jacoco", version.ref = "jacoco" }
85-
jruby = { module = "org.jruby:jruby", version.ref = "jruby" }
86-
junit4-latest = { module = "junit:junit", version.ref = "junit4" }
87-
junit4-bundle = { module = "org.apache.servicemix.bundles:org.apache.servicemix.bundles.junit", version = "4.13.2_1" }
88-
ktlint-cli = { module = "com.pinterest.ktlint:ktlint-cli", version.ref = "ktlint" }
96+
xmlunit-assertj = { module = "org.xmlunit:xmlunit-assertj3", version.ref = "xmlunit" }
97+
xmlunit-jakarta-jaxb-impl = { module = "org.xmlunit:xmlunit-jakarta-jaxb-impl", version.ref = "xmlunit" }
98+
xmlunit-placeholders = { module = "org.xmlunit:xmlunit-placeholders", version.ref = "xmlunit" }
8999

90100
[bundles]
91101
ant = ["ant", "ant-junit", "ant-junitlauncher"]
@@ -105,9 +115,9 @@ foojayResolver = { id = "org.gradle.toolchains.foojay-resolver", version = "1.0.
105115
gitPublish = { id = "org.ajoberstar.git-publish", version = "5.1.3" }
106116
jmh = { id = "me.champeau.jmh", version = "0.7.3" }
107117
jreleaser = { id = "org.jreleaser", version = "1.21.0" }
108-
# check if workaround in gradle.properties can be removed when updating
109-
kotlin = { id = "org.jetbrains.kotlin.jvm", version = "2.2.21" }
118+
kotlin = { id = "org.jetbrains.kotlin.jvm", version = "2.2.21" } # check if workaround in gradle.properties can be removed when updating
110119
nullaway = { id = "net.ltgt.nullaway", version = "2.3.0" }
111120
plantuml = { id = "io.freefair.plantuml", version = "9.1.0" }
121+
rewrite = { id = "org.openrewrite.rewrite", version = "7.21.0" }
112122
shadow = { id = "com.gradleup.shadow", version = "9.2.2" }
113123
spotless = { id = "com.diffplug.spotless", version = "8.0.0" }

gradle/plugins/common/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies {
1919
implementation(libs.plugins.nullaway.markerCoordinates)
2020
implementation(libs.plugins.shadow.markerCoordinates)
2121
implementation(libs.plugins.spotless.markerCoordinates)
22+
implementation(libs.plugins.rewrite.markerCoordinates)
2223
}
2324

2425
tasks.compileJava {

gradle/plugins/common/src/main/kotlin/junitbuild.base-conventions.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ plugins {
22
eclipse
33
id("junitbuild.java-toolchain-conventions")
44
id("junitbuild.spotless-conventions")
5+
id("junitbuild.rewrite-conventions")
56
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
plugins {
2+
id("org.openrewrite.rewrite")
3+
}
4+
5+
rewrite {
6+
activeRecipe("org.junit.openrewrite.SanityCheck")
7+
exclusion("**CollectionUtils.java")
8+
setExportDatatables(true)
9+
setFailOnDryRunResults(true)
10+
}
11+
12+
dependencies {
13+
rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:3.17.0"))
14+
rewrite("org.openrewrite.recipe:rewrite-migrate-java:3.20.0")
15+
rewrite("org.openrewrite.recipe:rewrite-java-security:3.19.2")
16+
rewrite("org.openrewrite.recipe:rewrite-rewrite:0.14.1")
17+
rewrite("org.openrewrite.recipe:rewrite-static-analysis:2.20.0")
18+
rewrite("org.openrewrite.recipe:rewrite-third-party:0.30.0")
19+
}

gradle/plugins/settings.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ rootProject.name = "plugins"
2121

2222
include("backward-compatibility")
2323
include("build-parameters")
24-
include("common")
2524
include("code-generator")
25+
include("common")
2626
include("publishing")
27+
include("rewrite")
2728

2829
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

junit-platform-commons/src/main/java/org/junit/platform/commons/support/ModifierSupport.java

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import static org.apiguardian.api.API.Status.MAINTAINED;
1515

1616
import java.lang.reflect.Member;
17+
import java.lang.reflect.Modifier;
1718

1819
import org.apiguardian.api.API;
1920
import org.junit.platform.commons.util.ReflectionUtils;
@@ -47,7 +48,7 @@ private ModifierSupport() {
4748
*
4849
* @param clazz the class to check; never {@code null}
4950
* @return {@code true} if the class is {@code public}
50-
* @see java.lang.reflect.Modifier#isPublic(int)
51+
* @see Modifier#isPublic(int)
5152
*/
5253
public static boolean isPublic(Class<?> clazz) {
5354
return ReflectionUtils.isPublic(clazz);
@@ -58,7 +59,7 @@ public static boolean isPublic(Class<?> clazz) {
5859
*
5960
* @param member the member to check; never {@code null}
6061
* @return {@code true} if the member is {@code public}
61-
* @see java.lang.reflect.Modifier#isPublic(int)
62+
* @see Modifier#isPublic(int)
6263
*/
6364
public static boolean isPublic(Member member) {
6465
return ReflectionUtils.isPublic(member);
@@ -69,7 +70,7 @@ public static boolean isPublic(Member member) {
6970
*
7071
* @param clazz the class to check; never {@code null}
7172
* @return {@code true} if the class is {@code private}
72-
* @see java.lang.reflect.Modifier#isPrivate(int)
73+
* @see Modifier#isPrivate(int)
7374
*/
7475
public static boolean isPrivate(Class<?> clazz) {
7576
return ReflectionUtils.isPrivate(clazz);
@@ -80,7 +81,7 @@ public static boolean isPrivate(Class<?> clazz) {
8081
*
8182
* @param member the member to check; never {@code null}
8283
* @return {@code true} if the member is {@code private}
83-
* @see java.lang.reflect.Modifier#isPrivate(int)
84+
* @see Modifier#isPrivate(int)
8485
*/
8586
public static boolean isPrivate(Member member) {
8687
return ReflectionUtils.isPrivate(member);
@@ -96,9 +97,9 @@ public static boolean isPrivate(Member member) {
9697
*
9798
* @param clazz the class to check; never {@code null}
9899
* @return {@code true} if the class is not {@code private}
99-
* @see java.lang.reflect.Modifier#isPublic(int)
100-
* @see java.lang.reflect.Modifier#isProtected(int)
101-
* @see java.lang.reflect.Modifier#isPrivate(int)
100+
* @see Modifier#isPublic(int)
101+
* @see Modifier#isProtected(int)
102+
* @see Modifier#isPrivate(int)
102103
*/
103104
public static boolean isNotPrivate(Class<?> clazz) {
104105
return ReflectionUtils.isNotPrivate(clazz);
@@ -114,9 +115,9 @@ public static boolean isNotPrivate(Class<?> clazz) {
114115
*
115116
* @param member the member to check; never {@code null}
116117
* @return {@code true} if the member is not {@code private}
117-
* @see java.lang.reflect.Modifier#isPublic(int)
118-
* @see java.lang.reflect.Modifier#isProtected(int)
119-
* @see java.lang.reflect.Modifier#isPrivate(int)
118+
* @see Modifier#isPublic(int)
119+
* @see Modifier#isProtected(int)
120+
* @see Modifier#isPrivate(int)
120121
*/
121122
public static boolean isNotPrivate(Member member) {
122123
return ReflectionUtils.isNotPrivate(member);
@@ -127,7 +128,7 @@ public static boolean isNotPrivate(Member member) {
127128
*
128129
* @param clazz the class to check; never {@code null}
129130
* @return {@code true} if the class is {@code abstract}
130-
* @see java.lang.reflect.Modifier#isAbstract(int)
131+
* @see Modifier#isAbstract(int)
131132
*/
132133
public static boolean isAbstract(Class<?> clazz) {
133134
return ReflectionUtils.isAbstract(clazz);
@@ -138,7 +139,7 @@ public static boolean isAbstract(Class<?> clazz) {
138139
*
139140
* @param member the class to check; never {@code null}
140141
* @return {@code true} if the member is {@code abstract}
141-
* @see java.lang.reflect.Modifier#isAbstract(int)
142+
* @see Modifier#isAbstract(int)
142143
*/
143144
public static boolean isAbstract(Member member) {
144145
return ReflectionUtils.isAbstract(member);
@@ -150,7 +151,7 @@ public static boolean isAbstract(Member member) {
150151
* @param clazz the class to check; never {@code null}
151152
* @return {@code true} if the class is not {@code abstract}
152153
* @since 1.13
153-
* @see java.lang.reflect.Modifier#isAbstract(int)
154+
* @see Modifier#isAbstract(int)
154155
*/
155156
@API(status = EXPERIMENTAL, since = "6.0")
156157
public static boolean isNotAbstract(Class<?> clazz) {
@@ -163,7 +164,7 @@ public static boolean isNotAbstract(Class<?> clazz) {
163164
* @param member the class to check; never {@code null}
164165
* @return {@code true} if the member is not {@code abstract}
165166
* @since 1.13
166-
* @see java.lang.reflect.Modifier#isAbstract(int)
167+
* @see Modifier#isAbstract(int)
167168
*/
168169
@API(status = EXPERIMENTAL, since = "6.0")
169170
public static boolean isNotAbstract(Member member) {
@@ -175,7 +176,7 @@ public static boolean isNotAbstract(Member member) {
175176
*
176177
* @param clazz the class to check; never {@code null}
177178
* @return {@code true} if the class is {@code static}
178-
* @see java.lang.reflect.Modifier#isStatic(int)
179+
* @see Modifier#isStatic(int)
179180
*/
180181
public static boolean isStatic(Class<?> clazz) {
181182
return ReflectionUtils.isStatic(clazz);
@@ -186,7 +187,7 @@ public static boolean isStatic(Class<?> clazz) {
186187
*
187188
* @param member the member to check; never {@code null}
188189
* @return {@code true} if the member is {@code static}
189-
* @see java.lang.reflect.Modifier#isStatic(int)
190+
* @see Modifier#isStatic(int)
190191
*/
191192
public static boolean isStatic(Member member) {
192193
return ReflectionUtils.isStatic(member);
@@ -197,7 +198,7 @@ public static boolean isStatic(Member member) {
197198
*
198199
* @param clazz the class to check; never {@code null}
199200
* @return {@code true} if the class is not {@code static}
200-
* @see java.lang.reflect.Modifier#isStatic(int)
201+
* @see Modifier#isStatic(int)
201202
*/
202203
public static boolean isNotStatic(Class<?> clazz) {
203204
return ReflectionUtils.isNotStatic(clazz);
@@ -208,7 +209,7 @@ public static boolean isNotStatic(Class<?> clazz) {
208209
*
209210
* @param member the member to check; never {@code null}
210211
* @return {@code true} if the member is not {@code static}
211-
* @see java.lang.reflect.Modifier#isStatic(int)
212+
* @see Modifier#isStatic(int)
212213
*/
213214
public static boolean isNotStatic(Member member) {
214215
return ReflectionUtils.isNotStatic(member);
@@ -220,7 +221,7 @@ public static boolean isNotStatic(Member member) {
220221
* @param clazz the class to check; never {@code null}
221222
* @return {@code true} if the class is {@code final}
222223
* @since 1.5
223-
* @see java.lang.reflect.Modifier#isFinal(int)
224+
* @see Modifier#isFinal(int)
224225
*/
225226
@API(status = MAINTAINED, since = "1.5")
226227
public static boolean isFinal(Class<?> clazz) {
@@ -233,7 +234,7 @@ public static boolean isFinal(Class<?> clazz) {
233234
* @param clazz the class to check; never {@code null}
234235
* @return {@code true} if the class is not {@code final}
235236
* @since 1.5
236-
* @see java.lang.reflect.Modifier#isFinal(int)
237+
* @see Modifier#isFinal(int)
237238
*/
238239
@API(status = MAINTAINED, since = "1.5")
239240
public static boolean isNotFinal(Class<?> clazz) {
@@ -246,7 +247,7 @@ public static boolean isNotFinal(Class<?> clazz) {
246247
* @param member the member to check; never {@code null}
247248
* @return {@code true} if the member is {@code final}
248249
* @since 1.5
249-
* @see java.lang.reflect.Modifier#isFinal(int)
250+
* @see Modifier#isFinal(int)
250251
*/
251252
@API(status = MAINTAINED, since = "1.5")
252253
public static boolean isFinal(Member member) {
@@ -259,7 +260,7 @@ public static boolean isFinal(Member member) {
259260
* @param member the member to check; never {@code null}
260261
* @return {@code true} if the member is not {@code final}
261262
* @since 1.5
262-
* @see java.lang.reflect.Modifier#isFinal(int)
263+
* @see Modifier#isFinal(int)
263264
*/
264265
@API(status = MAINTAINED, since = "1.5")
265266
public static boolean isNotFinal(Member member) {

0 commit comments

Comments
 (0)