From 3c9ab19466aa529b6ab6e67ba0c9ae5acc0a8238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sat, 17 Jan 2026 16:58:19 +0800 Subject: [PATCH] Replace ktlint with Spotless for code formatting - Add Spotless plugin 8.1.0 with ktlint 1.7.1 and Google Java Format - Configure ktlint rules, disable filename/max-line-length/property-naming - Remove old ktlint plugin --- app/build.gradle.kts | 26 +++++++++++++++----------- build.gradle.kts | 2 +- gradle/libs.versions.toml | 6 ++++++ 3 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/app/build.gradle.kts b/app/build.gradle.kts index abd8d3f..681949e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -2,7 +2,6 @@ import org.gradle.api.file.DuplicatesStrategy import org.gradle.api.tasks.Sync import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import org.jlleitschuh.gradle.ktlint.reporter.ReporterType import java.io.ByteArrayInputStream import java.io.FileInputStream import java.util.Base64 @@ -16,7 +15,7 @@ plugins { id("org.jetbrains.kotlin.plugin.compose") id("org.jetbrains.kotlin.plugin.serialization") id("com.github.triplet.play") - id("org.jlleitschuh.gradle.ktlint") + alias(libs.plugins.spotless) } fun getProps(propName: String): String { @@ -342,14 +341,19 @@ tasks.withType().configureEach { } } -ktlint { - android.set(false) - version.set("1.0.1") - verbose.set(true) - outputToConsole.set(true) - reporters { - reporter(ReporterType.PLAIN) - reporter(ReporterType.CHECKSTYLE) - reporter(ReporterType.HTML) +spotless { + kotlin { + target("src/**/*.kt") + ktlint(libs.versions.ktlint.get()) + .editorConfigOverride(mapOf( + "ktlint_standard_backing-property-naming" to "disabled", + "ktlint_standard_filename" to "disabled", + "ktlint_standard_max-line-length" to "disabled", + "ktlint_standard_property-naming" to "disabled", + )) + } + java { + target("src/**/*.java") + googleJavaFormat() } } diff --git a/build.gradle.kts b/build.gradle.kts index cd5e037..4b41f81 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { id("com.github.triplet.play") version "3.13.0" apply false id("org.jetbrains.kotlin.plugin.compose") version "2.2.0" apply false id("org.jetbrains.kotlin.plugin.serialization") version "2.2.0" apply false - id("org.jlleitschuh.gradle.ktlint") version "13.1.0" apply false + alias(libs.plugins.spotless) apply false id("io.gitlab.arturbosch.detekt") version "1.23.8" } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..d88dc34 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,6 @@ +[versions] +spotless = "8.1.0" +ktlint = "1.7.1" + +[plugins] +spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }