mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-11-21 20:55:41 +03:00
Add spotless (with ktlint) (#1136)
This commit is contained in:
parent
ac41bffdc9
commit
5ae8095ef1
10 changed files with 48 additions and 2 deletions
2
.github/workflows/build_pull_request.yml
vendored
2
.github/workflows/build_pull_request.yml
vendored
|
@ -38,7 +38,7 @@ jobs:
|
||||||
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
|
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
|
||||||
|
|
||||||
- name: Build app and run unit tests
|
- name: Build app and run unit tests
|
||||||
run: ./gradlew assembleStandardRelease testReleaseUnitTest testStandardReleaseUnitTest
|
run: ./gradlew spotlessCheck assembleStandardRelease testReleaseUnitTest testStandardReleaseUnitTest
|
||||||
|
|
||||||
- name: Upload APK
|
- name: Upload APK
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
|
2
.github/workflows/build_push.yml
vendored
2
.github/workflows/build_push.yml
vendored
|
@ -36,7 +36,7 @@ jobs:
|
||||||
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
|
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
|
||||||
|
|
||||||
- name: Build app and run unit tests
|
- name: Build app and run unit tests
|
||||||
run: ./gradlew assembleStandardRelease testReleaseUnitTest testStandardReleaseUnitTest
|
run: ./gradlew spotlessCheck assembleStandardRelease testReleaseUnitTest testStandardReleaseUnitTest
|
||||||
|
|
||||||
- name: Upload APK
|
- name: Upload APK
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
|
|
@ -6,6 +6,7 @@ dependencies {
|
||||||
implementation(androidx.gradle)
|
implementation(androidx.gradle)
|
||||||
implementation(kotlinx.gradle)
|
implementation(kotlinx.gradle)
|
||||||
implementation(kotlinx.compose.compiler.gradle)
|
implementation(kotlinx.compose.compiler.gradle)
|
||||||
|
implementation(libs.spotless.gradle)
|
||||||
implementation(gradleApi())
|
implementation(gradleApi())
|
||||||
|
|
||||||
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
|
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
|
||||||
|
|
|
@ -3,6 +3,8 @@ import mihon.buildlogic.configureCompose
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
kotlin("android")
|
kotlin("android")
|
||||||
|
|
||||||
|
id("mihon.code.lint")
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
|
@ -5,6 +5,8 @@ import mihon.buildlogic.configureTest
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
kotlin("android")
|
kotlin("android")
|
||||||
|
|
||||||
|
id("mihon.code.lint")
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
|
@ -4,6 +4,8 @@ import mihon.buildlogic.configureTest
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.test")
|
id("com.android.test")
|
||||||
kotlin("android")
|
kotlin("android")
|
||||||
|
|
||||||
|
id("mihon.code.lint")
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
30
buildSrc/src/main/kotlin/mihon.code.lint.gradle.kts
Normal file
30
buildSrc/src/main/kotlin/mihon.code.lint.gradle.kts
Normal 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()
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,8 @@ import mihon.buildlogic.configureCompose
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.library")
|
id("com.android.library")
|
||||||
|
|
||||||
|
id("mihon.code.lint")
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
|
@ -3,6 +3,8 @@ import mihon.buildlogic.configureTest
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.library")
|
id("com.android.library")
|
||||||
|
|
||||||
|
id("mihon.code.lint")
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
|
@ -8,6 +8,8 @@ shizuku_version = "12.2.0"
|
||||||
sqldelight = "2.0.2"
|
sqldelight = "2.0.2"
|
||||||
sqlite = "2.4.0"
|
sqlite = "2.4.0"
|
||||||
voyager = "1.0.0"
|
voyager = "1.0.0"
|
||||||
|
spotless = "6.25.0"
|
||||||
|
ktlint-core = "1.3.1"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
desugar = "com.android.tools:desugar_jdk_libs:2.0.4"
|
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-tab-navigator = { module = "cafe.adriel.voyager:voyager-tab-navigator", version.ref = "voyager" }
|
||||||
voyager-transitions = { module = "cafe.adriel.voyager:voyager-transitions", 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]
|
[bundles]
|
||||||
okhttp = ["okhttp-core", "okhttp-logging", "okhttp-brotli", "okhttp-dnsoverhttps"]
|
okhttp = ["okhttp-core", "okhttp-logging", "okhttp-brotli", "okhttp-dnsoverhttps"]
|
||||||
js-engine = ["quickjs-android"]
|
js-engine = ["quickjs-android"]
|
||||||
|
|
Loading…
Reference in a new issue