Skip to content

Commit a0379aa

Browse files
author
Vincent Potucek
committed
Add rewrite support
1 parent acc621e commit a0379aa

File tree

5 files changed

+53
-23
lines changed

5 files changed

+53
-23
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,25 @@ jobs:
3333
run: ./gradlew spotlessCheck
3434
- name: assemble testClasses
3535
run: ./gradlew assemble testClasses
36+
rewriteDryRun:
37+
name: rewriteDryRun
38+
runs-on: ubuntu-latest
39+
env:
40+
buildcacheuser: ${{ secrets.BUILDCACHE_USER }}
41+
buildcachepass: ${{ secrets.BUILDCACHE_PASS }}
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
- uses: actions/setup-java@v4
48+
with:
49+
distribution: "temurin"
50+
java-version: 21
51+
- name: gradle caching
52+
uses: gradle/actions/setup-gradle@v4
53+
- name: rewriteDryRun
54+
run: ./gradlew rewriteDryRun --build-cache --info
3655
build:
3756
needs: sanityCheck
3857
strategy:
@@ -66,10 +85,10 @@ jobs:
6685
uses: gradle/actions/setup-gradle@v4
6786
- name: build (maven-only)
6887
if: matrix.kind == 'maven'
69-
run: ./gradlew :plugin-maven:build -x spotlessCheck
88+
run: ./gradlew :plugin-maven:build -x spotlessCheck -x rewriteDryRun
7089
- name: build (everything-but-maven)
7190
if: matrix.kind == 'gradle'
72-
run: ./gradlew build -x spotlessCheck -PSPOTLESS_EXCLUDE_MAVEN=true
91+
run: ./gradlew build -x spotlessCheck -x rewriteDryRun -PSPOTLESS_EXCLUDE_MAVEN=true
7392
- name: test npm
7493
if: matrix.kind == 'npm'
7594
run: ./gradlew testNpm

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1616
* Adds support for worktrees (fixes [#1765](https://github.com/diffplug/spotless/issues/1765))
1717
* Bump default `google-java-format` version to latest `1.24.0` -> `1.28.0`. ([#2345](https://github.com/diffplug/spotless/pull/2345))
1818
* Bump default `ktlint` version to latest `1.5.0` -> `1.7.1`. ([#2555](https://github.com/diffplug/spotless/pull/2555))
19+
* Add `rewrite` support ([#2588](https://github.com/diffplug/spotless/pull/2588))
1920

2021
## [3.3.1] - 2025-07-21
2122
### Fixed

build.gradle

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,20 @@
11
apply plugin: 'dev.equo.ide'
2-
equoIde {
3-
branding().title('Spotless').icon(file('_images/spotless_logo.png'))
4-
welcome().openUrl('https://github.com/diffplug/spotless/blob/main/CONTRIBUTING.md')
5-
gradleBuildship().autoImport('.')
6-
}
72

8-
repositories {
9-
mavenCentral()
10-
}
11-
12-
apply from: rootProject.file('gradle/java-publish.gradle')
133
apply from: rootProject.file('gradle/changelog.gradle')
4+
apply from: rootProject.file('gradle/java-publish.gradle')
5+
apply from: rootProject.file('gradle/spotless-freshmark.gradle')
6+
147
allprojects {
158
apply from: rootProject.file('gradle/spotless.gradle')
9+
apply from: rootProject.file('gradle/rewrite.gradle')
10+
}
11+
12+
equoIde {
13+
branding().title('Spotless').icon(file('_images/spotless_logo.png'))
14+
welcome().openUrl('https://github.com/diffplug/spotless/blob/main/CONTRIBUTING.md')
15+
gradleBuildship().autoImport('.')
1616
}
17-
apply from: rootProject.file('gradle/spotless-freshmark.gradle')
1817

19-
spotless {
20-
groovyGradle {
21-
target '*.gradle', 'gradle/*.gradle'
22-
}
23-
format 'dotfiles', {
24-
target '.gitignore', '.gitattributes', '.editorconfig'
25-
leadingTabsToSpaces(2)
26-
trimTrailingWhitespace()
27-
endWithNewline()
28-
}
18+
dependencies {
19+
rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:latest.release"))
2920
}

gradle/rewrite.gradle

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apply plugin: 'org.openrewrite.rewrite'
2+
3+
rewrite {
4+
//activeRecipe("org.openrewrite.java.RemoveUnusedImports")
5+
// bugs
6+
exclusions.add("**AJacksonFormatterFunc.java")
7+
exclusions.add("**NpmPathResolver.java")
8+
exclusions.add("**NpmTestsWithoutNpmInstallationTest_gradle_node_plugin_example_*.gradle")
9+
exclusions.add("**gradle/changelog.gradle")
10+
exclusions.add("**gradle/java-publish.gradle")
11+
exclusions.add("**lib-extra/build.gradle")
12+
exclusions.add("**lib/build.gradle")
13+
exclusions.add("**package-info.java")
14+
exclusions.add("**plugin-maven/build.gradle")
15+
exclusions.add("**settings.gradle")
16+
exportDatatables = true
17+
failOnDryRunResults = true
18+
}

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ plugins {
2323
id 'com.gradle.develocity' version '3.19.2'
2424
// https://github.com/equodev/equo-ide/blob/main/plugin-gradle/CHANGELOG.md
2525
id 'dev.equo.ide' version '1.7.8' apply false
26+
id 'org.openrewrite.rewrite' version '7.12.1' apply false
2627
}
2728

2829
dependencyResolutionManagement {

0 commit comments

Comments
 (0)