diff --git a/buildSrc/src/main/kotlin/smithy-java.java-conventions.gradle.kts b/buildSrc/src/main/kotlin/smithy-java.java-conventions.gradle.kts index 7d62f4dcc..62998c134 100644 --- a/buildSrc/src/main/kotlin/smithy-java.java-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/smithy-java.java-conventions.gradle.kts @@ -1,7 +1,9 @@ +import com.diffplug.spotless.FormatterFunc import com.github.spotbugs.snom.Effort import java.util.regex.Pattern import org.gradle.api.Project import org.gradle.kotlin.dsl.the +import java.io.Serializable plugins { `java-library` @@ -75,15 +77,25 @@ spotless { // Enforce a common license header on all files licenseHeaderFile("${project.rootDir}/config/spotless/license-header.txt") .onlyIfContentMatches("^((?!SKIPLICENSECHECK)[\\s\\S])*\$") - indentWithSpaces() + leadingTabsToSpaces() endWithNewline() eclipse().configFile("${project.rootDir}/config/spotless/formatting.xml") // Fixes for some strange formatting applied by eclipse: // see: https://github.com/kamkie/demo-spring-jsf/blob/bcacb9dc90273a5f8d2569470c5bf67b171c7d62/build.gradle.kts#L159 - custom("Lambda fix") { it.replace("} )", "})").replace("} ,", "},") } - custom("Long literal fix") { Pattern.compile("([0-9_]+) [Ll]").matcher(it).replaceAll("\$1L") } + // These have to be implemented with anonymous classes this way instead of lambdas because of: + // https://github.com/diffplug/spotless/issues/2387 + custom("Lambda fix", object : Serializable, FormatterFunc { + override fun apply(input: String) : String { + return input.replace("} )", "})").replace("} ,", "},") + } + }) + custom("Long literal fix", object : Serializable, FormatterFunc { + override fun apply(input: String) : String { + return Pattern.compile("([0-9_]+) [Ll]").matcher(input).replaceAll("\$1L") + } + }) // Static first, then everything else alphabetically removeUnusedImports() @@ -96,7 +108,7 @@ spotless { // Formatting for build.gradle.kts files kotlinGradle { ktlint() - indentWithSpaces() + leadingTabsToSpaces() trimTrailingWhitespace() endWithNewline() } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2bbbf2c96..09e36bd0f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ smithy = "1.54.0" jmh = "0.7.3" test-logger-plugin = "4.0.0" spotbugs = "6.0.22" -spotless = "6.25.0" +spotless = "7.0.2" smithy-gradle-plugins = "1.2.0" assertj = "3.27.3" jackson = "2.18.2"