build-logic: migrate Spotless to a convention plugin
This commit is contained in:
parent
1040552dbf
commit
96a9211f9e
9 changed files with 62 additions and 34 deletions
1
build-logic/.gitignore
vendored
Normal file
1
build-logic/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/build
|
3
build-logic/build.gradle.kts
Normal file
3
build-logic/build.gradle.kts
Normal file
|
@ -0,0 +1,3 @@
|
|||
plugins { `kotlin-dsl` }
|
||||
|
||||
dependencies { implementation(libs.build.spotless) }
|
29
build-logic/settings.gradle.kts
Normal file
29
build-logic/settings.gradle.kts
Normal file
|
@ -0,0 +1,29 @@
|
|||
rootProject.name = "build-logic"
|
||||
|
||||
enableFeaturePreview("VERSION_CATALOGS")
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
versionCatalogs { create("libs") { from(files("../gradle/libs.versions.toml")) } }
|
||||
}
|
||||
|
||||
rootProject.name = "build-logic"
|
||||
|
||||
enableFeaturePreview("VERSION_CATALOGS")
|
||||
|
||||
include("android-plugins")
|
||||
|
||||
include("automation-plugins")
|
||||
|
||||
include("kotlin-plugins")
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
|
||||
* SPDX-License-Identifier: GPL-3.0-only
|
||||
*/
|
||||
plugins { id("com.diffplug.spotless") }
|
||||
|
||||
spotless {
|
||||
kotlin {
|
||||
ktfmt().googleStyle()
|
||||
target("**/*.kt")
|
||||
targetExclude("**/build/")
|
||||
}
|
||||
kotlinGradle {
|
||||
ktfmt().googleStyle()
|
||||
target("**/*.kts")
|
||||
}
|
||||
format("xml") {
|
||||
target("**/*.xml")
|
||||
targetExclude("**/build/", ".idea/")
|
||||
trimTrailingWhitespace()
|
||||
indentWithSpaces()
|
||||
endWithNewline()
|
||||
}
|
||||
}
|
|
@ -5,6 +5,5 @@
|
|||
plugins {
|
||||
`binary-compatibility-validator`
|
||||
`aps-plugin`
|
||||
id("com.github.android-password-store.spotless")
|
||||
}
|
||||
|
||||
allprojects { configureSpotless() }
|
||||
|
|
|
@ -34,7 +34,6 @@ gradlePlugin {
|
|||
|
||||
dependencies {
|
||||
implementation("com.android.tools.build:gradle:7.0.3")
|
||||
implementation("com.diffplug.spotless:spotless-plugin-gradle:5.16.0")
|
||||
implementation("com.google.dagger:hilt-android-gradle-plugin:2.40.1")
|
||||
implementation("com.squareup.okhttp3:okhttp:4.9.0")
|
||||
implementation("com.vanniktech:gradle-maven-publish-plugin:0.18.0")
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
|
||||
* SPDX-License-Identifier: GPL-3.0-only
|
||||
*/
|
||||
|
||||
import com.diffplug.gradle.spotless.SpotlessExtension
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
|
||||
fun Project.configureSpotless() {
|
||||
apply(plugin = "com.diffplug.spotless")
|
||||
configure<SpotlessExtension> {
|
||||
kotlin {
|
||||
ktfmt().googleStyle()
|
||||
target("**/*.kt")
|
||||
targetExclude("**/build/")
|
||||
}
|
||||
kotlinGradle {
|
||||
ktfmt().googleStyle()
|
||||
target("**/*.kts")
|
||||
}
|
||||
format("xml") {
|
||||
target("**/*.xml")
|
||||
targetExclude("**/build/", ".idea/")
|
||||
trimTrailingWhitespace()
|
||||
indentWithSpaces()
|
||||
endWithNewline()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,6 +11,9 @@ kotlin = "1.5.31"
|
|||
lifecycle = "2.4.0"
|
||||
|
||||
[libraries]
|
||||
# Plugins and other build tooling
|
||||
build-spotless = "com.diffplug.spotless:spotless-plugin-gradle:5.16.0"
|
||||
|
||||
# Kotlin dependencies
|
||||
kotlin-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
|
||||
kotlin-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
|
||||
|
|
|
@ -27,6 +27,7 @@ pluginManagement {
|
|||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
includeBuild("build-logic")
|
||||
}
|
||||
|
||||
dependencyResolutionManagement {
|
||||
|
|
Loading…
Reference in a new issue