Add spotless (with ktlint) (#1136)

This commit is contained in:
AntsyLich 2024-08-19 18:11:14 +06:00 committed by GitHub
parent ac41bffdc9
commit 5ae8095ef1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 48 additions and 2 deletions

View File

@ -38,7 +38,7 @@ jobs:
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
- name: Build app and run unit tests
run: ./gradlew assembleStandardRelease testReleaseUnitTest testStandardReleaseUnitTest
run: ./gradlew spotlessCheck assembleStandardRelease testReleaseUnitTest testStandardReleaseUnitTest
- name: Upload APK
uses: actions/upload-artifact@v4

View File

@ -36,7 +36,7 @@ jobs:
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
- name: Build app and run unit tests
run: ./gradlew assembleStandardRelease testReleaseUnitTest testStandardReleaseUnitTest
run: ./gradlew spotlessCheck assembleStandardRelease testReleaseUnitTest testStandardReleaseUnitTest
- name: Upload APK
uses: actions/upload-artifact@v4

View File

@ -6,6 +6,7 @@ dependencies {
implementation(androidx.gradle)
implementation(kotlinx.gradle)
implementation(kotlinx.compose.compiler.gradle)
implementation(libs.spotless.gradle)
implementation(gradleApi())
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))

View File

@ -3,6 +3,8 @@ import mihon.buildlogic.configureCompose
plugins {
id("com.android.application")
kotlin("android")
id("mihon.code.lint")
}
android {

View File

@ -5,6 +5,8 @@ import mihon.buildlogic.configureTest
plugins {
id("com.android.application")
kotlin("android")
id("mihon.code.lint")
}
android {

View File

@ -4,6 +4,8 @@ import mihon.buildlogic.configureTest
plugins {
id("com.android.test")
kotlin("android")
id("mihon.code.lint")
}
android {

View File

@ -0,0 +1,30 @@
import org.gradle.accessors.dm.LibrariesForLibs
plugins {
id("com.diffplug.spotless")
}
val libs = the<LibrariesForLibs>()
spotless {
kotlin {
target("**/*.kt", "**/*.kts")
targetExclude("**/build/**/*.kt")
ktlint(libs.ktlint.core.get().version)
.editorConfigOverride(mapOf(
"ktlint_function_naming_ignore_when_annotated_with" to "Composable",
"ktlint_standard_class-signature" to "disabled",
"ktlint_standard_discouraged-comment-location" to "disabled",
"ktlint_standard_function-expression-body" to "disabled",
"ktlint_standard_function-signature" to "disabled",
))
trimTrailingWhitespace()
endWithNewline()
}
format("xml") {
target("**/*.xml")
targetExclude("**/build/**/*.xml")
trimTrailingWhitespace()
endWithNewline()
}
}

View File

@ -2,6 +2,8 @@ import mihon.buildlogic.configureCompose
plugins {
id("com.android.library")
id("mihon.code.lint")
}
android {

View File

@ -3,6 +3,8 @@ import mihon.buildlogic.configureTest
plugins {
id("com.android.library")
id("mihon.code.lint")
}
android {

View File

@ -8,6 +8,8 @@ shizuku_version = "12.2.0"
sqldelight = "2.0.2"
sqlite = "2.4.0"
voyager = "1.0.0"
spotless = "6.25.0"
ktlint-core = "1.3.1"
[libraries]
desugar = "com.android.tools:desugar_jdk_libs:2.0.4"
@ -96,6 +98,9 @@ voyager-screenmodel = { module = "cafe.adriel.voyager:voyager-screenmodel", vers
voyager-tab-navigator = { module = "cafe.adriel.voyager:voyager-tab-navigator", version.ref = "voyager" }
voyager-transitions = { module = "cafe.adriel.voyager:voyager-transitions", version.ref = "voyager" }
spotless-gradle = { group = "com.diffplug.spotless", name = "spotless-plugin-gradle", version.ref = "spotless" }
ktlint-core = { module = "com.pinterest.ktlint:ktlint-cli", version.ref = "ktlint-core" }
[bundles]
okhttp = ["okhttp-core", "okhttp-logging", "okhttp-brotli", "okhttp-dnsoverhttps"]
js-engine = ["quickjs-android"]