From 87b5eacae87150fbfeb8cc7e3dfc5e300401aa8c Mon Sep 17 00:00:00 2001 From: Will Date: Mon, 6 Jan 2025 22:40:49 +1300 Subject: [PATCH] Swap to `ktfmt` (`googleStyle`), but keep `ktlint` for gradle scripts (#233) Seems like this is the way to go...? Related: https://github.com/will-molloy/java-template/pull/245 GitOrigin-RevId: 65b15a6b34bff8a4072558e718b2ed055c44ecf6 --- build.gradle.kts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 24e38682..f3e3feab 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -37,14 +37,19 @@ allprojects { apply(plugin = "com.diffplug.spotless") configure { + // https://github.com/diffplug/spotless/tree/main/plugin-gradle#java java { removeUnusedImports() googleJavaFormat() trimTrailingWhitespace() endWithNewline() } + // https://github.com/diffplug/spotless/tree/main/plugin-gradle#kotlin + // Compared to ktlint, it seems ktfmt is better for actual Kotlin code (more deterministic/consistent output). + // Furthermore, spotless is more for formatting than linting. + // However, it has some weird output with Gradle scripts, so using ktlint for that. kotlin { - ktlint().editorConfigOverride(mapOf("ktlint_standard_package-name" to "disabled")) + ktfmt().googleStyle() trimTrailingWhitespace() endWithNewline() } @@ -55,7 +60,7 @@ allprojects { } } - // TODO detekt for kotlin + // TODO Kotlin alternative? apply(plugin = "checkstyle") configure { toolVersion = "10.12.0"