File tree Expand file tree Collapse file tree 8 files changed +39
-15
lines changed
lib/src/main/java/com/diffplug/spotless/npm
plugin-maven/src/main/java/com/diffplug/spotless/maven Expand file tree Collapse file tree 8 files changed +39
-15
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ concurrency:
1313 cancel-in-progress : true
1414jobs :
1515 sanityCheck :
16- name : spotlessCheck assemble testClasses
16+ name : spotlessCheck rewriteDryRun assemble testClasses
1717 runs-on : ubuntu-latest
1818 env :
1919 buildcacheuser : ${{ secrets.BUILDCACHE_USER }}
3131 uses : gradle/actions/setup-gradle@v4
3232 - name : spotlessCheck
3333 run : ./gradlew spotlessCheck
34+ - name : rewriteDryRun
35+ run : ./gradlew rewriteDryRun
3436 - name : assemble testClasses
3537 run : ./gradlew assemble testClasses
3638 build :
@@ -66,10 +68,10 @@ jobs:
6668 uses : gradle/actions/setup-gradle@v4
6769 - name : build (maven-only)
6870 if : matrix.kind == 'maven'
69- run : ./gradlew :plugin-maven:build -x spotlessCheck
71+ run : ./gradlew :plugin-maven:build -x spotlessCheck -x rewriteDryRun
7072 - name : build (everything-but-maven)
7173 if : matrix.kind == 'gradle'
72- run : ./gradlew build -x spotlessCheck -PSPOTLESS_EXCLUDE_MAVEN=true
74+ run : ./gradlew build -x spotlessCheck -x rewriteDryRun - PSPOTLESS_EXCLUDE_MAVEN=true
7375 - name : test npm
7476 if : matrix.kind == 'npm'
7577 run : ./gradlew testNpm
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
2727### Added
2828* Add a ` lint ` mode to ` ReplaceRegexStep ` ([ #2571 ] ( https://github.com/diffplug/spotless/pull/2571 ) )
2929* ` LintSuppression ` now enforces unix-style paths in its ` setPath ` and ` relativizeAsUnix ` methods. ([ #2629 ] ( https://github.com/diffplug/spotless/pull/2629 ) )
30+ * Add ` rewrite ` support ([ #2588 ] ( https://github.com/diffplug/spotless/pull/2588 ) )
3031
3132## [ 3.3.1] - 2025-07-21
3233### Fixed
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ repositories {
1212apply from : rootProject. file(' gradle/java-publish.gradle' )
1313apply from : rootProject. file(' gradle/changelog.gradle' )
1414allprojects {
15+ apply from : rootProject. file(' gradle/rewrite.gradle' )
1516 apply from : rootProject. file(' gradle/spotless.gradle' )
1617}
1718apply from : rootProject. file(' gradle/spotless-freshmark.gradle' )
@@ -27,3 +28,7 @@ spotless {
2728 endWithNewline()
2829 }
2930}
31+
32+ dependencies {
33+ rewrite(" org.openrewrite.recipe:rewrite-third-party:0.27.0" )
34+ }
Original file line number Diff line number Diff line change 1+ apply plugin : ' org.openrewrite.rewrite'
2+
3+ rewrite {
4+ activeRecipe(" tech.picnic.errorprone.refasterrules.StreamRulesRecipes" )
5+ exclusions. addAll(
6+ " **_gradle_node_plugin_example_*.gradle" ,
7+ " **gradle/changelog.gradle" ,
8+ " **gradle/java-publish.gradle" ,
9+ " **lib-extra/build.gradle" ,
10+ " **lib/build.gradle" ,
11+ " **package-info.java" ,
12+ " **plugin-maven/build.gradle" ,
13+ " **settings.gradle"
14+ )
15+ exportDatatables = true
16+ failOnDryRunResults = true
17+ }
Original file line number Diff line number Diff line change 11/*
2- * Copyright 2020-2023 DiffPlug
2+ * Copyright 2020-2025 DiffPlug
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1818import static java .util .Objects .requireNonNull ;
1919
2020import java .io .File ;
21- import java .util .*;
21+ import java .util .ArrayList ;
22+ import java .util .Arrays ;
23+ import java .util .List ;
24+ import java .util .Optional ;
2225import java .util .function .Function ;
2326import java .util .function .Predicate ;
2427import java .util .function .Supplier ;
@@ -44,8 +47,8 @@ Optional<File> tryFind() {
4447 .stream ()
4548 .map (Supplier ::get )
4649 .filter (Optional ::isPresent )
47- .map ( Optional :: get )
48- .findFirst ();
50+ .findFirst ( )
51+ .orElseThrow ();
4952 }
5053
5154 static class Builder {
Original file line number Diff line number Diff line change @@ -81,11 +81,7 @@ public boolean isLayoutPrepared() {
8181 if (!packageLockJsonFile .isFile ()) {
8282 return false ;
8383 }
84- if (!serveJsFile ().isFile ()) {
85- return false ;
86- }
87- // npmrc is optional, so must not be checked here
88- return true ;
84+ return serveJsFile ().isFile (); // npmrc is optional, so must not be checked here
8985 }
9086
9187 public boolean isNodeModulesPrepared () {
@@ -96,7 +92,7 @@ public boolean isNodeModulesPrepared() {
9692 // check if it is NOT empty
9793 return ThrowingEx .get (() -> {
9894 try (Stream <Path > entries = Files .list (nodeModulesInstallDirPath )) {
99- return entries .findFirst ().isPresent ();
95+ return entries .findAny ().isPresent ();
10096 }
10197 });
10298 }
Original file line number Diff line number Diff line change @@ -414,8 +414,7 @@ private List<FormatterFactory> getFormatterFactories() {
414414 }
415415
416416 private List <FormatterStepFactory > getFormatterStepFactories () {
417- return Stream .of (licenseHeader )
418- .filter (Objects ::nonNull )
417+ return Stream .ofNullable (licenseHeader )
419418 .collect (toList ());
420419 }
421420
Original file line number Diff line number Diff 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.16.0' apply false
2627}
2728
2829dependencyResolutionManagement {
You can’t perform that action at this time.
0 commit comments