aboutsummaryrefslogtreecommitdiff
path: root/buildSrc/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'buildSrc/src/main/java')
-rw-r--r--buildSrc/src/main/java/BaseProjectConfig.kt6
-rw-r--r--buildSrc/src/main/java/CrowdinDownloadPlugin.kt8
-rw-r--r--buildSrc/src/main/java/Ktfmt.kt11
-rw-r--r--buildSrc/src/main/java/PasswordStorePlugin.kt13
-rw-r--r--buildSrc/src/main/java/Spotless.kt20
-rw-r--r--buildSrc/src/main/java/VersioningPlugin.kt28
6 files changed, 60 insertions, 26 deletions
diff --git a/buildSrc/src/main/java/BaseProjectConfig.kt b/buildSrc/src/main/java/BaseProjectConfig.kt
index 65426bf0..a6fb45f0 100644
--- a/buildSrc/src/main/java/BaseProjectConfig.kt
+++ b/buildSrc/src/main/java/BaseProjectConfig.kt
@@ -7,7 +7,6 @@ import com.android.build.gradle.TestedExtension
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Project
-import org.gradle.api.tasks.Delete
import org.gradle.api.tasks.testing.Test
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.gradle.api.tasks.wrapper.Wrapper
@@ -21,8 +20,6 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
* `buildscript` block in the top-level build.gradle.kts file.
*/
internal fun Project.configureForRootProject() {
- // register task for cleaning the build directory in the root project
- tasks.register("clean", Delete::class.java) { delete(rootProject.buildDir) }
tasks.withType<Wrapper> {
gradleVersion = "7.0"
distributionType = Wrapper.DistributionType.ALL
@@ -78,7 +75,8 @@ fun Project.isSnapshot(): Boolean {
/** Apply configurations for app module */
@Suppress("UnstableApiUsage")
internal fun BaseAppModuleExtension.configureAndroidApplicationOptions(project: Project) {
- val minifySwitch = project.providers.environmentVariable("DISABLE_MINIFY").forUseAtConfigurationTime()
+ val minifySwitch =
+ project.providers.environmentVariable("DISABLE_MINIFY").forUseAtConfigurationTime()
adbOptions.installOptions("--user 0")
diff --git a/buildSrc/src/main/java/CrowdinDownloadPlugin.kt b/buildSrc/src/main/java/CrowdinDownloadPlugin.kt
index 05fbabb8..4be93885 100644
--- a/buildSrc/src/main/java/CrowdinDownloadPlugin.kt
+++ b/buildSrc/src/main/java/CrowdinDownloadPlugin.kt
@@ -18,7 +18,8 @@ import org.w3c.dom.Document
private const val EXCEPTION_MESSAGE =
"""Applying `crowdin-plugin` requires a projectName to be configured via the "crowdin" extension."""
-private const val CROWDIN_BUILD_API_URL = "https://api.crowdin.com/api/project/%s/export?login=%s&account-key=%s"
+private const val CROWDIN_BUILD_API_URL =
+ "https://api.crowdin.com/api/project/%s/export?login=%s&account-key=%s"
class CrowdinDownloadPlugin : Plugin<Project> {
@@ -69,7 +70,10 @@ class CrowdinDownloadPlugin : Plugin<Project> {
doLast {
val sourceSets = arrayOf("main", "nonFree")
for (sourceSet in sourceSets) {
- val stringFiles = File("${projectDir}/src/$sourceSet").walkTopDown().filter { it.name == "strings.xml" }
+ val stringFiles =
+ File("${projectDir}/src/$sourceSet").walkTopDown().filter {
+ it.name == "strings.xml"
+ }
val sourceFile =
stringFiles.firstOrNull { it.path.endsWith("values/strings.xml") }
?: throw GradleException("No root strings.xml found in '$sourceSet' sourceSet")
diff --git a/buildSrc/src/main/java/Ktfmt.kt b/buildSrc/src/main/java/Ktfmt.kt
deleted file mode 100644
index 49a90a06..00000000
--- a/buildSrc/src/main/java/Ktfmt.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-import com.ncorti.ktfmt.gradle.KtfmtExtension
-
-fun KtfmtExtension.configureKtfmt() {
- googleStyle()
- maxWidth.set(120)
-}
diff --git a/buildSrc/src/main/java/PasswordStorePlugin.kt b/buildSrc/src/main/java/PasswordStorePlugin.kt
index f4923e04..aa2f152f 100644
--- a/buildSrc/src/main/java/PasswordStorePlugin.kt
+++ b/buildSrc/src/main/java/PasswordStorePlugin.kt
@@ -7,8 +7,8 @@ import com.android.build.gradle.TestedExtension
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
import com.android.build.gradle.internal.plugins.AppPlugin
import com.android.build.gradle.internal.plugins.LibraryPlugin
-import com.ncorti.ktfmt.gradle.KtfmtExtension
-import com.ncorti.ktfmt.gradle.KtfmtPlugin
+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.api.plugins.JavaLibraryPlugin
@@ -45,12 +45,15 @@ class PasswordStorePlugin : Plugin<Project> {
project.configureExplicitApi()
}
is AppPlugin -> {
- project.extensions.getByType<BaseAppModuleExtension>().configureAndroidApplicationOptions(project)
+ project
+ .extensions
+ .getByType<BaseAppModuleExtension>()
+ .configureAndroidApplicationOptions(project)
project.extensions.getByType<BaseAppModuleExtension>().configureBuildSigning(project)
project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions()
}
- is KtfmtPlugin -> {
- project.extensions.getByType<KtfmtExtension>().configureKtfmt()
+ is SpotlessPlugin -> {
+ project.extensions.getByType<SpotlessExtension>().configureSpotless()
}
is SigningPlugin -> {
project.extensions.getByType<SigningExtension>().configureBuildSigning()
diff --git a/buildSrc/src/main/java/Spotless.kt b/buildSrc/src/main/java/Spotless.kt
new file mode 100644
index 00000000..1422e12b
--- /dev/null
+++ b/buildSrc/src/main/java/Spotless.kt
@@ -0,0 +1,20 @@
+/*
+ * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+import com.diffplug.gradle.spotless.SpotlessExtension
+
+internal fun SpotlessExtension.configureSpotless() {
+ ratchetFrom = "origin/develop"
+ kotlin {
+ ktfmt().googleStyle()
+ target("src/**/*.kt", "**/*.kts")
+ }
+ format("xml") {
+ target("**/*.xml")
+ trimTrailingWhitespace()
+ indentWithSpaces()
+ endWithNewline()
+ }
+}
diff --git a/buildSrc/src/main/java/VersioningPlugin.kt b/buildSrc/src/main/java/VersioningPlugin.kt
index 30ca5895..1ebbd9b8 100644
--- a/buildSrc/src/main/java/VersioningPlugin.kt
+++ b/buildSrc/src/main/java/VersioningPlugin.kt
@@ -69,16 +69,36 @@ class VersioningPlugin : Plugin<Project> {
doLast { version.withClearedSuffix().writeForAndroid(propFile.asFile.outputStream()) }
}
tasks.register("bumpMajor") {
- doLast { version.withIncMajor().withClearedSuffix().writeForAndroid(propFile.asFile.outputStream()) }
+ doLast {
+ version
+ .withIncMajor()
+ .withClearedSuffix()
+ .writeForAndroid(propFile.asFile.outputStream())
+ }
}
tasks.register("bumpMinor") {
- doLast { version.withIncMinor().withClearedSuffix().writeForAndroid(propFile.asFile.outputStream()) }
+ doLast {
+ version
+ .withIncMinor()
+ .withClearedSuffix()
+ .writeForAndroid(propFile.asFile.outputStream())
+ }
}
tasks.register("bumpPatch") {
- doLast { version.withIncPatch().withClearedSuffix().writeForAndroid(propFile.asFile.outputStream()) }
+ doLast {
+ version
+ .withIncPatch()
+ .withClearedSuffix()
+ .writeForAndroid(propFile.asFile.outputStream())
+ }
}
tasks.register("bumpSnapshot") {
- doLast { version.withIncMinor().withSuffix("SNAPSHOT").writeForAndroid(propFile.asFile.outputStream()) }
+ doLast {
+ version
+ .withIncMinor()
+ .withSuffix("SNAPSHOT")
+ .writeForAndroid(propFile.asFile.outputStream())
+ }
}
}
}