Skip to content

Commit d6c09b2

Browse files
author
Vincent Potucek
committed
Add rewrite support for RemoveUnusedImports
1 parent 93068b4 commit d6c09b2

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ jobs:
141141
# --no-scan: For public fork PRs, we won't attempt to publish the scan
142142
run: |
143143
./gradlew --build-cache --info $SCAN_ARG check releaseTarGz -x test
144+
- name: rewriteDryRun
145+
run: ./gradlew rewriteDryRun --build-cache -Dorg.gradle.jvmargs=-Xmx8G
146+
# https://docs.openrewrite.org/reference/faq#im-getting-javalangoutofmemoryerror-java-heap-space-when-running-openrewrite
147+
timeout-minutes: 90
144148
- name: Archive check reports
145149
if: always()
146150
uses: actions/upload-artifact@v4

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,16 @@ The import order is a part of static check. please call `spotlessApply` to optim
203203

204204
./gradlew spotlessApply
205205

206+
#### Rewrite
207+
The build system incorporates [Moderne](https://moderne.io/) rewrite capabilities for automated code transformations.
208+
209+
- **Convention** (e.g., JUnit's naming rules)
210+
- **Refactor** safely (e.g., rename methods, migrate APIs)
211+
- **Modernize** (e.g., Java 8 → Java 17 features)
212+
- **Patterns** (e.g., replace `Vector` with `ArrayList`)
213+
214+
`./gradlew rewriteRun`
215+
206216
#### Spotbugs ####
207217
Spotbugs uses static analysis to look for bugs in the code.
208218
You can run spotbugs using:

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ plugins {
4141
id 'org.scoverage' version '8.0.3' apply false
4242
id 'com.gradleup.shadow' version '8.3.6' apply false
4343
id 'com.diffplug.spotless' version "6.25.0"
44+
id "org.openrewrite.rewrite" version "7.12.1"
4445
}
4546

47+
apply from: "gradle/.qa/rewrite.gradle"
48+
4649
ext {
4750
gradleVersion = versions.gradle
4851
minClientJavaVersion = 11

gradle/.qa/rewrite.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
rewrite {
19+
//activeRecipe("org.openrewrite.java.RemoveUnusedImports")
20+
exportDatatables = true
21+
exclusions.add("**.GarbageCollectedMemoryPoolTest.java")
22+
exclusions.add("**.MetadataVersionTest.java")
23+
failOnDryRunResults = true
24+
}
25+
26+
dependencies {
27+
rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:latest.release"))
28+
}

0 commit comments

Comments
 (0)