Skip to content

Add rewrite support #2588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,27 @@ jobs:
run: ./gradlew spotlessCheck
- name: assemble testClasses
run: ./gradlew assemble testClasses
rewriteDryRun:
name: rewriteDryRun
runs-on: ubuntu-latest
env:
buildcacheuser: ${{ secrets.BUILDCACHE_USER }}
buildcachepass: ${{ secrets.BUILDCACHE_PASS }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 21
- name: gradle caching
uses: gradle/actions/setup-gradle@v4
- name: rewriteDryRun
run: ./gradlew rewriteDryRun --build-cache --info
build:
needs: sanityCheck
needs: [sanityCheck, rewriteDryRun]
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -66,10 +85,10 @@ jobs:
uses: gradle/actions/setup-gradle@v4
- name: build (maven-only)
if: matrix.kind == 'maven'
run: ./gradlew :plugin-maven:build -x spotlessCheck
run: ./gradlew :plugin-maven:build -x spotlessCheck -x rewriteDryRun
- name: build (everything-but-maven)
if: matrix.kind == 'gradle'
run: ./gradlew build -x spotlessCheck -PSPOTLESS_EXCLUDE_MAVEN=true
run: ./gradlew build -x spotlessCheck -x rewriteDryRun -PSPOTLESS_EXCLUDE_MAVEN=true
- name: test npm
if: matrix.kind == 'npm'
run: ./gradlew testNpm
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
* Adds support for worktrees (fixes [#1765](https://github.com/diffplug/spotless/issues/1765))
* Bump default `google-java-format` version to latest `1.24.0` -> `1.28.0`. ([#2345](https://github.com/diffplug/spotless/pull/2345))
* Bump default `ktlint` version to latest `1.5.0` -> `1.7.1`. ([#2555](https://github.com/diffplug/spotless/pull/2555))
* Add `rewrite` support ([#2588](https://github.com/diffplug/spotless/pull/2588))

## [3.3.1] - 2025-07-21
### Fixed
Expand Down
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ apply from: rootProject.file('gradle/java-publish.gradle')
apply from: rootProject.file('gradle/changelog.gradle')
allprojects {
apply from: rootProject.file('gradle/spotless.gradle')
apply from: rootProject.file('gradle/rewrite.gradle')
}
apply from: rootProject.file('gradle/spotless-freshmark.gradle')

Expand All @@ -27,3 +28,7 @@ spotless {
endWithNewline()
}
}

dependencies {
rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:latest.release"))
}
18 changes: 18 additions & 0 deletions gradle/rewrite.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apply plugin: 'org.openrewrite.rewrite'

rewrite {
//activeRecipe("org.openrewrite.java.RemoveUnusedImports")
// bugs
exclusions.add("**AJacksonFormatterFunc.java")
exclusions.add("**NpmPathResolver.java")
exclusions.add("**NpmTestsWithoutNpmInstallationTest_gradle_node_plugin_example_*.gradle")
exclusions.add("**gradle/changelog.gradle")
exclusions.add("**gradle/java-publish.gradle")
exclusions.add("**lib-extra/build.gradle")
exclusions.add("**lib/build.gradle")
exclusions.add("**package-info.java")
exclusions.add("**plugin-maven/build.gradle")
exclusions.add("**settings.gradle")
exportDatatables = true
failOnDryRunResults = true
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ plugins {
id 'com.gradle.develocity' version '3.19.2'
// https://github.com/equodev/equo-ide/blob/main/plugin-gradle/CHANGELOG.md
id 'dev.equo.ide' version '1.7.8' apply false
id 'org.openrewrite.rewrite' version '7.12.1' apply false
}

dependencyResolutionManagement {
Expand Down
Loading