diff --git a/build-logic/.gitignore b/build-logic/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/build-logic/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts new file mode 100644 index 00000000..070eb82a --- /dev/null +++ b/build-logic/build.gradle.kts @@ -0,0 +1,3 @@ +plugins { `kotlin-dsl` } + +dependencies { implementation(libs.build.spotless) } diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts new file mode 100644 index 00000000..6afc1258 --- /dev/null +++ b/build-logic/settings.gradle.kts @@ -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") diff --git a/build-logic/src/main/kotlin/com.github.android-password-store.spotless.gradle.kts b/build-logic/src/main/kotlin/com.github.android-password-store.spotless.gradle.kts new file mode 100644 index 00000000..3d5e589d --- /dev/null +++ b/build-logic/src/main/kotlin/com.github.android-password-store.spotless.gradle.kts @@ -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() + } +} diff --git a/build.gradle.kts b/build.gradle.kts index a04020c8..b0556c0e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,6 +5,5 @@ plugins { `binary-compatibility-validator` `aps-plugin` + id("com.github.android-password-store.spotless") } - -allprojects { configureSpotless() } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 6c4786e8..d1e60299 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -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") diff --git a/buildSrc/src/main/java/Spotless.kt b/buildSrc/src/main/java/Spotless.kt deleted file mode 100644 index bab6f58d..00000000 --- a/buildSrc/src/main/java/Spotless.kt +++ /dev/null @@ -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 { - kotlin { - ktfmt().googleStyle() - target("**/*.kt") - targetExclude("**/build/") - } - kotlinGradle { - ktfmt().googleStyle() - target("**/*.kts") - } - format("xml") { - target("**/*.xml") - targetExclude("**/build/", ".idea/") - trimTrailingWhitespace() - indentWithSpaces() - endWithNewline() - } - } -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index af24329b..baa6df1d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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" } diff --git a/settings.gradle.kts b/settings.gradle.kts index c8c641b8..3fc42f05 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -27,6 +27,7 @@ pluginManagement { mavenCentral() gradlePluginPortal() } + includeBuild("build-logic") } dependencyResolutionManagement {