Skip to content

Commit 33e064b

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 33e064b

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import com.diffplug.spotless.FormatterFunc
12
import com.github.spotbugs.snom.Effort
23
import java.util.regex.Pattern
34
import org.gradle.api.Project
45
import org.gradle.kotlin.dsl.the
6+
import java.io.Serializable
57

68
plugins {
79
`java-library`
@@ -75,15 +77,25 @@ spotless {
7577
// Enforce a common license header on all files
7678
licenseHeaderFile("${project.rootDir}/config/spotless/license-header.txt")
7779
.onlyIfContentMatches("^((?!SKIPLICENSECHECK)[\\s\\S])*\$")
78-
indentWithSpaces()
80+
leadingTabsToSpaces()
7981
endWithNewline()
8082

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

8385
// Fixes for some strange formatting applied by eclipse:
8486
// 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") }
87+
// These have to be implemented with anonymous classes this way instead of lambdas because of:
88+
// https://github.com/diffplug/spotless/issues/2387
89+
custom("Lambda fix", object : Serializable, FormatterFunc {
90+
override fun apply(input: String) : String {
91+
return input.replace("} )", "})").replace("} ,", "},")
92+
}
93+
})
94+
custom("Long literal fix", object : Serializable, FormatterFunc {
95+
override fun apply(input: String) : String {
96+
return Pattern.compile("([0-9_]+) [Ll]").matcher(input).replaceAll("\$1L")
97+
}
98+
})
8799

88100
// Static first, then everything else alphabetically
89101
removeUnusedImports()
@@ -96,7 +108,7 @@ spotless {
96108
// Formatting for build.gradle.kts files
97109
kotlinGradle {
98110
ktlint()
99-
indentWithSpaces()
111+
leadingTabsToSpaces()
100112
trimTrailingWhitespace()
101113
endWithNewline()
102114
}

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)