Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion .run/spotlessApply.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="--init-script=gradle/init.gradle.kts" />
<option name="taskDescriptions">
<list />
</option>
Expand Down
31 changes: 31 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,35 @@ 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
}


subprojects {
apply(plugin = "com.diffplug.spotless")
extensions.configure<com.diffplug.gradle.spotless.SpotlessExtension> {
kotlin {
target("**/*.kt")
targetExclude("**/build/**/*.kt")
ktlint(libs.versions.ktlint.get()).editorConfigOverride(
mapOf(
"android" to "true",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule looks invalid for now.

"ktlint_standard_property-naming" to "disabled"
),
)
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
}
kotlinGradle {
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"), "(^(?![\\/ ]\\*).*$)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can reuse the license config for both kt and kts files. ktlint() should also be applied for kts.

}
format("xml") {
target("**/*.xml")
targetExclude("**/build/**/*.xml")
// Look for the first XML tag that isn't a comment (<!--) or the xml declaration (<?xml)
licenseHeaderFile(rootProject.file("spotless/copyright.xml"), "(<[^!?])")
}
}
}
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ksp = "2.1.20-1.0.32"
kotlinxCoroutines = "1.10.2"
kotlinxSerialization = "2.1.20"
kotlinxSerializationJson = "1.8.1"
ktlint = "1.5.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this could be refed by a dependency, so that the version will be tracked and updated by automatons like @renovate-bot.

lifecycleRuntimeKtx = "2.8.7"
lifecycleViewmodelNavigation3 = "1.0.0-SNAPSHOT"
loggingInterceptor = "5.0.0-alpha.14"
Expand All @@ -49,6 +50,7 @@ poseDetection = "18.0.0-beta5"
profileinstaller = "1.4.1"
retrofit = "2.11.0"
robolectric = "4.14.1"
spotless = "7.0.2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
spotless = "7.0.2"
spotless = "7.0.4"

startup = "1.2.0"
runner = "1.6.2"
uiTextGoogleFonts = "1.8.0"
Expand Down Expand Up @@ -142,3 +144,4 @@ serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref
android-test = { id = "com.android.test", version.ref = "agp" }
baselineprofile = { id = "androidx.baselineprofile", version.ref = "baselineprofile" }
composeScreenshot = { id = "com.android.compose.screenshot", version = "0.0.1-alpha09" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }