From 12a667c7420242c51f1131655c25bc2210c7c00d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Feb 2025 14:42:42 +0000 Subject: [PATCH 1/2] Bump com.diffplug.spotless:spotless-plugin-gradle in /codegen Bumps [com.diffplug.spotless:spotless-plugin-gradle](https://github.com/diffplug/spotless) from 6.25.0 to 7.0.2. - [Release notes](https://github.com/diffplug/spotless/releases) - [Changelog](https://github.com/diffplug/spotless/blob/main/CHANGES.md) - [Commits](https://github.com/diffplug/spotless/compare/gradle/6.25.0...gradle/7.0.2) --- updated-dependencies: - dependency-name: com.diffplug.spotless:spotless-plugin-gradle dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- codegen/gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen/gradle/libs.versions.toml b/codegen/gradle/libs.versions.toml index 9a7270687..136377030 100644 --- a/codegen/gradle/libs.versions.toml +++ b/codegen/gradle/libs.versions.toml @@ -3,7 +3,7 @@ junit5 = "5.11.4" smithy = "1.54.0" test-logger-plugin = "4.0.0" spotbugs = "6.0.22" -spotless = "6.25.0" +spotless = "7.0.2" smithy-gradle-plugins = "1.2.0" dep-analysis = "2.8.2" From ba3db184b6fcb2bfae2abbf261c85e2fe507c728 Mon Sep 17 00:00:00 2001 From: JordonPhillips Date: Wed, 26 Feb 2025 17:15:30 +0100 Subject: [PATCH 2/2] Avoid lambda functions in spotless config Kotlin lambdas can't be serialized effectively by {spotless / gradle} right now so this replaces those lambdas with anonymous classes that implement `FormatterFunc` --- .../smithy-python.java-conventions.gradle.kts | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/codegen/buildSrc/src/main/kotlin/smithy-python.java-conventions.gradle.kts b/codegen/buildSrc/src/main/kotlin/smithy-python.java-conventions.gradle.kts index ed30456ad..278c72bd1 100644 --- a/codegen/buildSrc/src/main/kotlin/smithy-python.java-conventions.gradle.kts +++ b/codegen/buildSrc/src/main/kotlin/smithy-python.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` @@ -71,15 +73,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() @@ -92,7 +104,7 @@ spotless { // Formatting for build.gradle.kts files kotlinGradle { ktlint() - indentWithSpaces() + leadingTabsToSpaces() trimTrailingWhitespace() endWithNewline() }