From 1be1948f494acfbd1505eab35e8071159ba495f5 Mon Sep 17 00:00:00 2001 From: xfy Date: Fri, 22 May 2026 16:37:29 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E9=9B=86=E6=88=90=20Spotless=208.5.1?= =?UTF-8?q?=20=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E5=8C=96=E5=B7=A5?= =?UTF-8?q?=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在版本目录中添加 spotless 插件 8.5.1 - 配置 Kotlin 源码和 Gradle Kotlin DSL 脚本格式化 - 使用 ktlint 引擎,启用 trimTrailingWhitespace 和 endWithNewline Co-Authored-By: Claude Opus 4.7 (1M context) --- build.gradle.kts | 19 ++++++++++++++++++- gradle/libs.versions.toml | 2 ++ settings.gradle.kts | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 6a61282..ad8b05e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,4 +4,21 @@ plugins { alias(libs.plugins.androidApplication) apply false alias(libs.plugins.androidLibrary) apply false alias(libs.plugins.composeCompiler) apply false -} \ No newline at end of file + alias(libs.plugins.spotless) +} + +spotless { + kotlin { + target("src/**/*.kt") + targetExclude("${layout.buildDirectory}/**/*.kt") + ktlint() + trimTrailingWhitespace() + endWithNewline() + } + kotlinGradle { + target("*.gradle.kts") + ktlint() + trimTrailingWhitespace() + endWithNewline() + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1b8183c..270d9a3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,6 @@ [versions] agp = "9.2.1" +spotless = "8.5.1" android-compileSdk = "37" android-minSdk = "24" android-targetSdk = "37" @@ -47,3 +48,4 @@ androidLibrary = { id = "com.android.library", version.ref = "agp" } composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } androidTest = { id = "com.android.test", version.ref = "agp" } kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } diff --git a/settings.gradle.kts b/settings.gradle.kts index a0677c0..dac493e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -30,4 +30,4 @@ dependencyResolutionManagement { include(":core") include(":app") -include(":macrobenchmark") \ No newline at end of file +include(":macrobenchmark")