Skip to content

Commit

Permalink
Use Initialization Scripts for spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
fornewid committed Dec 9, 2023
1 parent 008816a commit 577b7e4
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 20 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# https://editorconfig.org/
# This configuration is used by ktlint when spotless invokes it

[*.{kt,kts}]
ij_kotlin_allow_trailing_comma=true
ij_kotlin_allow_trailing_comma_on_call_site=true
21 changes: 17 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ on:
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 40
timeout-minutes: 60

steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3

- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
Expand All @@ -27,5 +28,17 @@ jobs:
distribution: temurin
java-version: 17

- name: Build, lint and spotless
run: ./gradlew spotlessCheck dependencyGuard lintDebug assemble --scan
- name: Check dependencyGuard
run: ./gradlew dependencyGuard

- name: Check spotless
run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --stacktrace

- name: Check lint
run: ./gradlew lintDebug --stacktrace

- name: Build all build type and flavor permutations
run: ./gradlew assemble --stacktrace

- name: Run local tests
run: ./gradlew testDebug --stacktrace
15 changes: 0 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.dagger.hilt) apply false
alias(libs.plugins.spotless) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.dependencyGuard) apply false
alias(libs.plugins.firebase.crashlytics) apply false
Expand All @@ -14,20 +13,6 @@ plugins {

apply from: "$rootDir/gradle/version.gradle"

subprojects {
apply plugin: 'com.diffplug.spotless'
spotless {
kotlin {
target '**/*.kt'
targetExclude("$buildDir/**/*.kt")
targetExclude('bin/**/*.kt')

ktlint("0.41.0")
licenseHeaderFile rootProject.file('spotless/copyright.kt')
}
}
}

Object propOrDef(String propertyName, Object defaultValue) {
def properties = new Properties()
def keyFile = rootProject.file("signing/key.properties")
Expand Down
28 changes: 28 additions & 0 deletions gradle/init.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
val ktlintVersion = "0.49.0"

initscript {
val spotlessVersion = "6.22.0"

repositories {
mavenCentral()
}

dependencies {
classpath("com.diffplug.spotless:spotless-plugin-gradle:$spotlessVersion")
}
}

allprojects {
if (this == rootProject) {
return@allprojects
}
apply<com.diffplug.gradle.spotless.SpotlessPlugin>()
extensions.configure<com.diffplug.gradle.spotless.SpotlessExtension> {
kotlin {
target("**/*.kt")
targetExclude("**/build/**/*.kt")
ktlint(ktlintVersion).userData(mapOf("android" to "true"))
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
}
}
}
1 change: 0 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ dagger-hilt = { id = "com.google.dagger.hilt.android", version.ref = "dagger" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
spotless = { id = "com.diffplug.spotless", version = "6.11.0" }
dependencyGuard = { id = "com.dropbox.dependency-guard", version.ref = "dependencyGuard" }
firebase-crashlytics = { id = "com.google.firebase.crashlytics", version = "2.9.2" }
firebase-perf = { id = "com.google.firebase.firebase-perf", version = "1.4.2" }

0 comments on commit 577b7e4

Please sign in to comment.