Skip to content

Commit 1db2777

Browse files
Bump spotless to v7
This updates spotless to v7 Kotlin lambdas can't be serialized effectively by {spotless / gradle} right now so this replaces those lambdas with anonymous classes that implement `FormatterFunc`
1 parent 16950dd commit 1db2777

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

buildSrc/src/main/kotlin/smithy-java.java-conventions.gradle.kts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,25 @@ spotless {
7575
// Enforce a common license header on all files
7676
licenseHeaderFile("${project.rootDir}/config/spotless/license-header.txt")
7777
.onlyIfContentMatches("^((?!SKIPLICENSECHECK)[\\s\\S])*\$")
78-
indentWithSpaces()
78+
leadingTabsToSpaces()
7979
endWithNewline()
8080

8181
eclipse().configFile("${project.rootDir}/config/spotless/formatting.xml")
8282

8383
// Fixes for some strange formatting applied by eclipse:
8484
// see: https://github.com/kamkie/demo-spring-jsf/blob/bcacb9dc90273a5f8d2569470c5bf67b171c7d62/build.gradle.kts#L159
85-
custom("Lambda fix") { it.replace("} )", "})").replace("} ,", "},") }
86-
custom("Long literal fix") { Pattern.compile("([0-9_]+) [Ll]").matcher(it).replaceAll("\$1L") }
85+
// These have to be implemented with anonymous classes this way instead of lambdas because of:
86+
// https://github.com/diffplug/spotless/issues/2387
87+
custom("Lambda fix", object : Serializable, FormatterFunc {
88+
override fun apply(input: String) : String {
89+
return input.replace("} )", "})").replace("} ,", "},")
90+
}
91+
})
92+
custom("Long literal fix", object : Serializable, FormatterFunc {
93+
override fun apply(input: String) : String {
94+
return Pattern.compile("([0-9_]+) [Ll]").matcher(input).replaceAll("\$1L")
95+
}
96+
})
8797

8898
// Static first, then everything else alphabetically
8999
removeUnusedImports()
@@ -96,7 +106,7 @@ spotless {
96106
// Formatting for build.gradle.kts files
97107
kotlinGradle {
98108
ktlint()
99-
indentWithSpaces()
109+
leadingTabsToSpaces()
100110
trimTrailingWhitespace()
101111
endWithNewline()
102112
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ smithy = "1.54.0"
55
jmh = "0.7.3"
66
test-logger-plugin = "4.0.0"
77
spotbugs = "6.0.22"
8-
spotless = "6.25.0"
8+
spotless = "7.0.2"
99
smithy-gradle-plugins = "1.2.0"
1010
assertj = "3.27.3"
1111
jackson = "2.18.2"

0 commit comments

Comments
 (0)