Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
feat(build): replace homebrew ktfmt formatter with Spotless
Browse files Browse the repository at this point in the history
Spotless has fixed their Gradle Configuration Cache woes in the past
couple months which gets rid of my primary complaint.
  • Loading branch information
msfjarvis committed Aug 13, 2024
1 parent 3af68b4 commit b699b4d
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 243 deletions.
12 changes: 11 additions & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@
"datasourceTemplate": "maven",
"depNameTemplate": "androidx.compose.compiler:compiler",
"registryUrlTemplate": "https://maven.google.com",
}
},
{
"fileMatch": [
"build-logic/src/main/kotlin/app/passwordstore/gradle/SpotlessPlugin.kt"
],
"matchStrings": [
"KTFMT_VERSION = \"(?<currentValue>.*)\""
],
"datasourceTemplate": "maven",
"depNameTemplate": "com.facebook:ktfmt"
}
]
}
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- name: Check codestyle
shell: bash
run: ./gradlew ktfmtCheck
run: ./gradlew spotlessCheck

- name: Upload Kotlin build report
if: "${{ always() }}"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-pl-rPL/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<resources>
<plurals name="delete_title">
<item quantity="one">Wybrano %d element</item>
<item quantity="few">Wybrano %d elementy
<item quantity="few">Wybrano %d elementy
(If: 2,3,4)</item>
<item quantity="many">Wybrano %d elementów</item>
<item quantity="other">Liczba wybranych elementów: %d</item>
Expand Down
10 changes: 5 additions & 5 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ gradlePlugin {
id = "com.github.android-password-store.kotlin-jvm-library"
implementationClass = "app.passwordstore.gradle.KotlinJVMLibrary"
}
register("ktfmt") {
id = "com.github.android-password-store.ktfmt"
implementationClass = "app.passwordstore.gradle.KtfmtPlugin"
}
register("published-android-library") {
id = "com.github.android-password-store.published-android-library"
implementationClass = "app.passwordstore.gradle.PublishedAndroidLibraryPlugin"
Expand All @@ -61,6 +57,10 @@ gradlePlugin {
id = "com.github.android-password-store.sentry"
implementationClass = "app.passwordstore.gradle.SentryPlugin"
}
register("spotless") {
id = "com.github.android-password-store.spotless"
implementationClass = "app.passwordstore.gradle.SpotlessPlugin"
}
register("versioning") {
id = "com.github.android-password-store.versioning-plugin"
implementationClass = "app.passwordstore.gradle.versioning.VersioningPlugin"
Expand All @@ -79,7 +79,6 @@ dependencies {
implementation(libs.build.download)
implementation(libs.build.javapoet)
implementation(libs.build.kotlin)
implementation(libs.build.ktfmt)
implementation(libs.build.mavenpublish)
implementation(libs.build.metalava)
implementation(libs.build.moshi)
Expand All @@ -88,6 +87,7 @@ dependencies {
implementation(libs.build.r8)
implementation(libs.build.semver)
implementation(libs.build.sentry)
implementation(libs.build.spotless)
implementation(libs.build.vcu)
implementation(libs.kotlinx.coroutines.core)

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/

package app.passwordstore.gradle

import com.diffplug.gradle.spotless.SpotlessExtension
import com.diffplug.gradle.spotless.SpotlessPlugin
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.getByType

@Suppress("Unused")
class SpotlessPlugin : Plugin<Project> {

override fun apply(project: Project) {
project.pluginManager.apply(SpotlessPlugin::class)
project.extensions.getByType<SpotlessExtension>().run {
kotlin {
ktfmt(KTFMT_VERSION).googleStyle()
target("**/*.kt")
targetExclude("**/build/")
}
kotlinGradle {
ktfmt(KTFMT_VERSION).googleStyle()
target("**/*.kts")
targetExclude("**/build/")
}
format("xml") {
target("**/*.xml")
targetExclude("**/build/", ".idea/")
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
}
}

private companion object {
private const val KTFMT_VERSION = "0.51"
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
plugins {
id("com.github.android-password-store.git-hooks")
id("com.github.android-password-store.kotlin-common")
id("com.github.android-password-store.ktfmt")
id("com.github.android-password-store.spotless")
id("com.github.android-password-store.versions")
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ build-diffutils = "io.github.java-diff-utils:java-diff-utils:4.12"
build-download = "de.undercouch:gradle-download-task:5.6.0"
build-javapoet = "com.squareup:javapoet:1.13.0"
build-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
build-ktfmt = "com.facebook:ktfmt:0.51"
build-mavenpublish = "com.vanniktech:gradle-maven-publish-plugin:0.29.0"
build-metalava = "me.tylerbwong.gradle.metalava:plugin:0.3.5"
build-moshi = { module = "com.squareup.moshi:moshi", version.ref = "moshi" }
Expand All @@ -48,6 +47,7 @@ build-okhttp = "com.squareup.okhttp3:okhttp:5.0.0-alpha.14"
build-r8 = "com.android.tools:r8:8.4.6-dev"
build-semver = "com.github.zafarkhaja:java-semver:0.10.2"
build-sentry = "io.sentry.android.gradle:io.sentry.android.gradle.gradle.plugin:4.11.0"
build-spotless = "com.diffplug.spotless:spotless-plugin-gradle:6.25.0"
build-vcu = "nl.littlerobots.version-catalog-update:nl.littlerobots.version-catalog-update.gradle.plugin:0.8.4"
compose-bom = "androidx.compose:compose-bom:2024.06.00"
compose-foundation-core = { module = "androidx.compose.foundation:foundation" }
Expand Down
2 changes: 1 addition & 1 deletion scripts/pre-push-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ while read -r local_ref local_oid remote_ref remote_oid; do
_=$remote_ref
_=$remote_oid
if [ "${local_oid}" != "${ZERO}" ]; then
CI=true "${GRADLE_EXEC}" metalavaCheckCompatibilityRelease lint ktfmtCheck test -PslimTests
CI=true "${GRADLE_EXEC}" metalavaCheckCompatibilityRelease lint spotlessCheck test -PslimTests
fi
done

0 comments on commit b699b4d

Please sign in to comment.