From aea89047b6e05a157187b56656fe726a8b1e9e2b Mon Sep 17 00:00:00 2001 From: Rebecca Franks Date: Fri, 20 Jun 2025 15:23:49 +0100 Subject: [PATCH 1/2] Remove the need to have separate spotless config --- .github/workflows/build_and_test.yml | 2 +- .run/spotlessApply.run.xml | 1 - build.gradle.kts | 32 ++++++++++++++++++++++++++++ gradle/libs.versions.toml | 2 ++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 6866d8f4..c991d1ad 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -40,7 +40,7 @@ jobs: run: chmod +x gradlew - name: Apply Spotless - run: ./gradlew spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache + run: ./gradlew spotlessApply - name: Commit Spotless changes uses: stefanzweifel/git-auto-commit-action@v5 diff --git a/.run/spotlessApply.run.xml b/.run/spotlessApply.run.xml index c9e02b96..02cbc78f 100644 --- a/.run/spotlessApply.run.xml +++ b/.run/spotlessApply.run.xml @@ -19,7 +19,6 @@ diff --git a/build.gradle.kts b/build.gradle.kts index 72b0e280..65f14420 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,4 +11,36 @@ plugins { alias(libs.plugins.crashlytics) apply false alias(libs.plugins.android.test) apply false alias(libs.plugins.baselineprofile) apply false + alias(libs.plugins.spotless) apply false +} + +val ktlintVersion = "1.5.0" + +subprojects { + apply(plugin = "com.diffplug.spotless") + extensions.configure { + kotlin { + target("**/*.kt") + targetExclude("**/build/**/*.kt") + ktlint(ktlintVersion).editorConfigOverride( + mapOf( + "android" to "true", + "ktlint_standard_property-naming" to "disabled" + ), + ) + licenseHeaderFile(rootProject.file("spotless/copyright.kt")) + } + format("kts") { + target("**/*.kts") + targetExclude("**/build/**/*.kts") + // Look for the first line that doesn't have a block comment (assumed to be the license) + licenseHeaderFile(rootProject.file("spotless/copyright.kts"), "(^(?![\\/ ]\\*).*$)") + } + format("xml") { + target("**/*.xml") + targetExclude("**/build/**/*.xml") + // Look for the first XML tag that isn't a comment (