summaryrefslogtreecommitdiff
path: root/build-logic/android-plugins
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2022-12-02 01:57:02 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2022-12-02 01:57:02 +0530
commitafd0eebdd3287d932c53879fa1ac88f430080ef5 (patch)
tree141b9147325b96f4ab3a49927e4a1d997f3c37be /build-logic/android-plugins
parent54bb4676a7c16d959769e522ac018f3e3e822797 (diff)
refactor(build-logic): move all code to a single top-level project
Diffstat (limited to 'build-logic/android-plugins')
-rw-r--r--build-logic/android-plugins/build.gradle.kts64
-rw-r--r--build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt55
-rw-r--r--build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/ApplicationPlugin.kt81
-rw-r--r--build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/LibraryPlugin.kt15
-rw-r--r--build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/PublishedAndroidLibraryPlugin.kt47
-rw-r--r--build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/RenameArtifactsPlugin.kt40
-rw-r--r--build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/SentryPlugin.kt44
-rw-r--r--build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/artifacts/CollectApksTask.kt44
-rw-r--r--build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/artifacts/CollectBundleTask.kt33
-rw-r--r--build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/flavors/ProductFlavors.kt15
-rw-r--r--build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/flavors/SlimTests.kt44
-rw-r--r--build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/signing/AppSigning.kt36
-rw-r--r--build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/snapshot/SnapshotExtension.kt10
-rw-r--r--build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/versioning/Constants.kt14
-rw-r--r--build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/versioning/VersioningPlugin.kt88
-rw-r--r--build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/versioning/VersioningTask.kt50
16 files changed, 0 insertions, 680 deletions
diff --git a/build-logic/android-plugins/build.gradle.kts b/build-logic/android-plugins/build.gradle.kts
deleted file mode 100644
index 23a14da0..00000000
--- a/build-logic/android-plugins/build.gradle.kts
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
- * SPDX-License-Identifier: GPL-3.0-only
- */
-@file:Suppress("DSL_SCOPE_VIOLATION", "UnstableApiUsage")
-
-import org.gradle.api.JavaVersion
-import org.gradle.api.tasks.compile.JavaCompile
-import org.gradle.kotlin.dsl.withType
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
-plugins { `kotlin-dsl` }
-
-afterEvaluate {
- tasks.withType<JavaCompile>().configureEach {
- sourceCompatibility = JavaVersion.VERSION_11.toString()
- targetCompatibility = JavaVersion.VERSION_11.toString()
- }
-
- tasks.withType<KotlinCompile>().configureEach {
- kotlinOptions {
- jvmTarget = JavaVersion.VERSION_11.toString()
- freeCompilerArgs = freeCompilerArgs + "-Xsam-conversions=class"
- }
- }
-}
-
-gradlePlugin {
- plugins {
- register("versioning") {
- id = "com.github.android-password-store.versioning-plugin"
- implementationClass = "app.passwordstore.gradle.versioning.VersioningPlugin"
- }
- register("android-application") {
- id = "com.github.android-password-store.android-application"
- implementationClass = "app.passwordstore.gradle.ApplicationPlugin"
- }
- register("android-library") {
- id = "com.github.android-password-store.android-library"
- implementationClass = "app.passwordstore.gradle.LibraryPlugin"
- }
- register("published-android-library") {
- id = "com.github.android-password-store.published-android-library"
- implementationClass = "app.passwordstore.gradle.PublishedAndroidLibraryPlugin"
- }
- register("rename-artifacts") {
- id = "com.github.android-password-store.rename-artifacts"
- implementationClass = "app.passwordstore.gradle.RenameArtifactsPlugin"
- }
- register("sentry") {
- id = "com.github.android-password-store.sentry"
- implementationClass = "app.passwordstore.gradle.SentryPlugin"
- }
- }
-}
-
-dependencies {
- implementation(libs.build.agp)
- implementation(libs.build.mavenpublish)
- implementation(libs.build.metalava)
- implementation(libs.build.r8)
- implementation(libs.build.semver)
- implementation(libs.build.sentry)
-}
diff --git a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt b/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt
deleted file mode 100644
index 5e38b6eb..00000000
--- a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt
+++ /dev/null
@@ -1,55 +0,0 @@
-package app.passwordstore.gradle
-
-import app.passwordstore.gradle.flavors.configureSlimTests
-import com.android.build.gradle.TestedExtension
-import org.gradle.api.JavaVersion
-import org.gradle.api.Project
-import org.gradle.api.tasks.testing.Test
-import org.gradle.kotlin.dsl.configure
-import org.gradle.kotlin.dsl.withType
-
-@Suppress("UnstableApiUsage")
-object AndroidCommon {
- fun configure(project: Project) {
- project.extensions.configure<TestedExtension> {
- setCompileSdkVersion(33)
- defaultConfig {
- minSdk = 23
- targetSdk = 31
- }
-
- sourceSets {
- named("main") { java.srcDirs("src/main/kotlin") }
- named("test") { java.srcDirs("src/test/kotlin") }
- named("androidTest") { java.srcDirs("src/androidTest/kotlin") }
- }
-
- packagingOptions {
- resources.excludes.add("**/*.version")
- resources.excludes.add("**/*.txt")
- resources.excludes.add("**/*.kotlin_module")
- resources.excludes.add("**/plugin.properties")
- resources.excludes.add("**/META-INF/AL2.0")
- resources.excludes.add("**/META-INF/LGPL2.1")
- }
-
- compileOptions {
- sourceCompatibility = JavaVersion.VERSION_11
- targetCompatibility = JavaVersion.VERSION_11
- }
-
- testOptions {
- animationsDisabled = true
- unitTests.isReturnDefaultValues = true
- }
- project.tasks.withType<Test> {
- jvmArgs(
- "--add-opens=java.base/java.lang=ALL-UNNAMED",
- "--add-opens=java.base/java.util=ALL-UNNAMED",
- )
- }
-
- project.configureSlimTests()
- }
- }
-}
diff --git a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/ApplicationPlugin.kt b/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/ApplicationPlugin.kt
deleted file mode 100644
index bf759b3c..00000000
--- a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/ApplicationPlugin.kt
+++ /dev/null
@@ -1,81 +0,0 @@
-@file:Suppress("UnstableApiUsage")
-
-package app.passwordstore.gradle
-
-import app.passwordstore.gradle.flavors.FlavorDimensions
-import app.passwordstore.gradle.flavors.ProductFlavors
-import app.passwordstore.gradle.signing.configureBuildSigning
-import app.passwordstore.gradle.snapshot.SnapshotExtension
-import com.android.build.gradle.AppPlugin
-import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
-import org.gradle.api.Plugin
-import org.gradle.api.Project
-import org.gradle.kotlin.dsl.apply
-import org.gradle.kotlin.dsl.dependencies
-import org.gradle.kotlin.dsl.getByType
-import org.gradle.kotlin.dsl.the
-
-@Suppress("Unused")
-class ApplicationPlugin : Plugin<Project> {
-
- override fun apply(project: Project) {
- project.pluginManager.apply(AppPlugin::class)
- AndroidCommon.configure(project)
- project.extensions.getByType<BaseAppModuleExtension>().run {
- val minifySwitch = project.providers.environmentVariable("DISABLE_MINIFY")
-
- adbOptions.installOptions("--user 0")
-
- dependenciesInfo {
- includeInBundle = false
- includeInApk = false
- }
-
- buildFeatures {
- viewBinding = true
- buildConfig = true
- }
-
- buildTypes {
- named("release") {
- isMinifyEnabled = !minifySwitch.isPresent
- setProguardFiles(
- listOf(
- "proguard-android-optimize.txt",
- "proguard-rules.pro",
- "proguard-rules-missing-classes.pro",
- )
- )
- buildConfigField("boolean", "ENABLE_DEBUG_FEATURES", "${project.isSnapshot()}")
- }
- named("debug") {
- applicationIdSuffix = ".debug"
- versionNameSuffix = "-debug"
- isMinifyEnabled = false
- buildConfigField("boolean", "ENABLE_DEBUG_FEATURES", "true")
- }
- }
-
- flavorDimensions.add(FlavorDimensions.FREE)
- productFlavors {
- register(ProductFlavors.FREE) {}
- register(ProductFlavors.NON_FREE) {}
- }
-
- project.configureBuildSigning()
- }
-
- project.dependencies {
- extensions.add("snapshot", SnapshotExtension::class.java)
- the<SnapshotExtension>().snapshot = project.isSnapshot()
- }
- }
-
- private fun Project.isSnapshot(): Boolean {
- with(project.providers) {
- val workflow = environmentVariable("GITHUB_WORKFLOW")
- val snapshot = environmentVariable("SNAPSHOT")
- return workflow.isPresent || snapshot.isPresent
- }
- }
-}
diff --git a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/LibraryPlugin.kt b/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/LibraryPlugin.kt
deleted file mode 100644
index 22cc8ca3..00000000
--- a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/LibraryPlugin.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-package app.passwordstore.gradle
-
-import com.android.build.gradle.LibraryPlugin
-import org.gradle.api.Plugin
-import org.gradle.api.Project
-import org.gradle.kotlin.dsl.apply
-
-@Suppress("Unused")
-class LibraryPlugin : Plugin<Project> {
-
- override fun apply(project: Project) {
- project.pluginManager.apply(LibraryPlugin::class)
- AndroidCommon.configure(project)
- }
-}
diff --git a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/PublishedAndroidLibraryPlugin.kt b/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/PublishedAndroidLibraryPlugin.kt
deleted file mode 100644
index 542bfeb6..00000000
--- a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/PublishedAndroidLibraryPlugin.kt
+++ /dev/null
@@ -1,47 +0,0 @@
-@file:Suppress("UnstableApiUsage")
-
-package app.passwordstore.gradle
-
-import com.vanniktech.maven.publish.MavenPublishBaseExtension
-import com.vanniktech.maven.publish.MavenPublishPlugin
-import com.vanniktech.maven.publish.SonatypeHost
-import me.tylerbwong.gradle.metalava.Documentation
-import me.tylerbwong.gradle.metalava.extension.MetalavaExtension
-import org.gradle.api.Plugin
-import org.gradle.api.Project
-import org.gradle.kotlin.dsl.apply
-import org.gradle.kotlin.dsl.getByType
-import org.gradle.kotlin.dsl.provideDelegate
-import org.gradle.plugins.signing.SigningExtension
-import org.gradle.plugins.signing.SigningPlugin
-
-@Suppress("Unused")
-class PublishedAndroidLibraryPlugin : Plugin<Project> {
-
- override fun apply(project: Project) {
- project.plugins.run {
- apply(LibraryPlugin::class)
- apply(MavenPublishPlugin::class)
- apply(SigningPlugin::class)
- apply("me.tylerbwong.gradle.metalava")
- }
- project.extensions.getByType<MavenPublishBaseExtension>().run {
- publishToMavenCentral(SonatypeHost.DEFAULT, true)
- signAllPublications()
- }
- project.afterEvaluate {
- project.extensions.getByType<SigningExtension>().run {
- val signingKey: String? by project
- val signingPassword: String? by project
- useInMemoryPgpKeys(signingKey, signingPassword)
- }
- }
- project.extensions.getByType<MetalavaExtension>().run {
- documentation.set(Documentation.PUBLIC)
- inputKotlinNulls.set(true)
- outputKotlinNulls.set(true)
- reportLintsAsErrors.set(true)
- reportWarningsAsErrors.set(true)
- }
- }
-}
diff --git a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/RenameArtifactsPlugin.kt b/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/RenameArtifactsPlugin.kt
deleted file mode 100644
index 6807b6ef..00000000
--- a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/RenameArtifactsPlugin.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-package app.passwordstore.gradle
-
-import app.passwordstore.gradle.artifacts.CollectApksTask
-import app.passwordstore.gradle.artifacts.CollectBundleTask
-import com.android.build.api.artifact.SingleArtifact
-import com.android.build.api.variant.ApplicationAndroidComponentsExtension
-import com.android.build.api.variant.VariantOutputConfiguration
-import org.gradle.api.Plugin
-import org.gradle.api.Project
-import org.gradle.kotlin.dsl.getByType
-import org.gradle.kotlin.dsl.register
-
-@Suppress("Unused")
-class RenameArtifactsPlugin : Plugin<Project> {
-
- override fun apply(project: Project) {
- project.pluginManager.withPlugin("com.android.application") {
- project.extensions.getByType<ApplicationAndroidComponentsExtension>().run {
- onVariants { variant ->
- project.tasks.register<CollectApksTask>("collect${variant.name.capitalize()}Apks") {
- variantName.set(variant.name)
- apkFolder.set(variant.artifacts.get(SingleArtifact.APK))
- builtArtifactsLoader.set(variant.artifacts.getBuiltArtifactsLoader())
- outputDirectory.set(project.layout.projectDirectory.dir("outputs"))
- }
- project.tasks.register<CollectBundleTask>("collect${variant.name.capitalize()}Bundle") {
- val mainOutput =
- variant.outputs.single {
- it.outputType == VariantOutputConfiguration.OutputType.SINGLE
- }
- variantName.set(variant.name)
- versionName.set(mainOutput.versionName)
- bundleFile.set(variant.artifacts.get(SingleArtifact.BUNDLE))
- outputDirectory.set(project.layout.projectDirectory.dir("outputs"))
- }
- }
- }
- }
- }
-}
diff --git a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/SentryPlugin.kt b/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/SentryPlugin.kt
deleted file mode 100644
index 034c62f9..00000000
--- a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/SentryPlugin.kt
+++ /dev/null
@@ -1,44 +0,0 @@
-package app.passwordstore.gradle
-
-import app.passwordstore.gradle.flavors.FlavorDimensions
-import app.passwordstore.gradle.flavors.ProductFlavors
-import com.android.build.api.variant.ApplicationAndroidComponentsExtension
-import io.sentry.android.gradle.SentryPlugin
-import io.sentry.android.gradle.extensions.SentryPluginExtension
-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 SentryPlugin : Plugin<Project> {
-
- override fun apply(project: Project) {
- project.pluginManager.withPlugin("com.android.application") {
- project.extensions.getByType<ApplicationAndroidComponentsExtension>().run {
- onVariants(selector().withFlavor(FlavorDimensions.FREE to ProductFlavors.NON_FREE)) {
- variant ->
- val sentryDsn = project.providers.environmentVariable(SENTRY_DSN_PROPERTY)
- if (sentryDsn.isPresent) {
- variant.manifestPlaceholders.put("sentryDsn", sentryDsn.get())
- }
- }
- }
- project.plugins.apply(SentryPlugin::class)
- project.extensions.getByType<SentryPluginExtension>().run {
- autoUploadProguardMapping.set(
- project.providers.gradleProperty(SENTRY_UPLOAD_MAPPINGS_PROPERTY).isPresent
- )
- ignoredBuildTypes.set(setOf("debug"))
- ignoredFlavors.set(setOf(ProductFlavors.FREE))
- tracingInstrumentation { enabled.set(false) }
- autoInstallation.enabled.set(false)
- }
- }
- }
-
- private companion object {
- private const val SENTRY_DSN_PROPERTY = "SENTRY_DSN"
- private const val SENTRY_UPLOAD_MAPPINGS_PROPERTY = "sentryUploadMappings"
- }
-}
diff --git a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/artifacts/CollectApksTask.kt b/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/artifacts/CollectApksTask.kt
deleted file mode 100644
index 4f74136c..00000000
--- a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/artifacts/CollectApksTask.kt
+++ /dev/null
@@ -1,44 +0,0 @@
-package app.passwordstore.gradle.artifacts
-
-import com.android.build.api.variant.BuiltArtifactsLoader
-import java.nio.file.Files
-import java.nio.file.Paths
-import java.nio.file.StandardCopyOption
-import org.gradle.api.DefaultTask
-import org.gradle.api.file.DirectoryProperty
-import org.gradle.api.provider.Property
-import org.gradle.api.tasks.CacheableTask
-import org.gradle.api.tasks.Input
-import org.gradle.api.tasks.InputFiles
-import org.gradle.api.tasks.Internal
-import org.gradle.api.tasks.OutputDirectory
-import org.gradle.api.tasks.PathSensitive
-import org.gradle.api.tasks.PathSensitivity
-import org.gradle.api.tasks.TaskAction
-
-/** Task to collect APKs in a given [outputDirectory]. */
-@CacheableTask
-abstract class CollectApksTask : DefaultTask() {
- @get:InputFiles @get:PathSensitive(PathSensitivity.NONE) abstract val apkFolder: DirectoryProperty
-
- @get:Input abstract val variantName: Property<String>
-
- @get:Internal abstract val builtArtifactsLoader: Property<BuiltArtifactsLoader>
-
- @get:OutputDirectory abstract val outputDirectory: DirectoryProperty
-
- @TaskAction
- fun run() {
- val outputDir = outputDirectory.asFile.get()
- outputDir.mkdirs()
- val builtArtifacts =
- builtArtifactsLoader.get().load(apkFolder.get()) ?: throw RuntimeException("Cannot load APKs")
- builtArtifacts.elements.forEach { artifact ->
- Files.copy(
- Paths.get(artifact.outputFile),
- outputDir.resolve("APS-${variantName.get()}-${artifact.versionName}.apk").toPath(),
- StandardCopyOption.REPLACE_EXISTING,
- )
- }
- }
-}
diff --git a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/artifacts/CollectBundleTask.kt b/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/artifacts/CollectBundleTask.kt
deleted file mode 100644
index b627a674..00000000
--- a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/artifacts/CollectBundleTask.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-package app.passwordstore.gradle.artifacts
-
-import java.nio.file.Files
-import java.nio.file.StandardCopyOption
-import org.gradle.api.DefaultTask
-import org.gradle.api.file.DirectoryProperty
-import org.gradle.api.file.RegularFileProperty
-import org.gradle.api.provider.Property
-import org.gradle.api.tasks.Input
-import org.gradle.api.tasks.InputFile
-import org.gradle.api.tasks.OutputDirectory
-import org.gradle.api.tasks.TaskAction
-
-abstract class CollectBundleTask : DefaultTask() {
- @get:InputFile abstract val bundleFile: RegularFileProperty
-
- @get:Input abstract val variantName: Property<String>
-
- @get:Input abstract val versionName: Property<String>
-
- @get:OutputDirectory abstract val outputDirectory: DirectoryProperty
-
- @TaskAction
- fun taskAction() {
- val outputDir = outputDirectory.asFile.get()
- outputDir.mkdirs()
- Files.copy(
- bundleFile.get().asFile.toPath(),
- outputDir.resolve("APS-${variantName.get()}-${versionName.get()}.aab").toPath(),
- StandardCopyOption.REPLACE_EXISTING,
- )
- }
-}
diff --git a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/flavors/ProductFlavors.kt b/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/flavors/ProductFlavors.kt
deleted file mode 100644
index e4b5c739..00000000
--- a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/flavors/ProductFlavors.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-package app.passwordstore.gradle.flavors
-
-object FlavorDimensions {
- const val FREE = "free"
-}
-
-object ProductFlavors {
- const val FREE = "free"
- const val NON_FREE = "nonFree"
-}
diff --git a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/flavors/SlimTests.kt b/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/flavors/SlimTests.kt
deleted file mode 100644
index 8755a872..00000000
--- a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/flavors/SlimTests.kt
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-package app.passwordstore.gradle.flavors
-
-import com.android.build.api.variant.ApplicationAndroidComponentsExtension
-import com.android.build.api.variant.LibraryAndroidComponentsExtension
-import org.gradle.api.Project
-import org.gradle.kotlin.dsl.findByType
-import org.gradle.language.nativeplatform.internal.BuildType
-
-/**
- * When the "slimTests" project property is provided, disable the unit test tasks on `release` build
- * type and `nonFree` product flavor to avoid running the same tests repeatedly in different build
- * variants.
- *
- * Examples: `./gradlew test -PslimTests` will run unit tests for `nonFreeDebug` and `debug` build
- * variants in Android App and Library projects, and all tests in JVM projects.
- */
-internal fun Project.configureSlimTests() {
- if (providers.gradleProperty(SLIM_TESTS_PROPERTY).isPresent) {
- // disable unit test tasks on the release build type for Android Library projects
- extensions.findByType<LibraryAndroidComponentsExtension>()?.run {
- beforeVariants(selector().withBuildType(BuildType.RELEASE.name)) {
- it.enableUnitTest = false
- it.enableAndroidTest = false
- }
- }
-
- // disable unit test tasks on the release build type and free flavor for Android Application
- // projects.
- extensions.findByType<ApplicationAndroidComponentsExtension>()?.run {
- beforeVariants(selector().withBuildType(BuildType.RELEASE.name)) { it.enableUnitTest = false }
- beforeVariants(selector().withFlavor(FlavorDimensions.FREE to ProductFlavors.NON_FREE)) {
- it.enableUnitTest = false
- it.enableAndroidTest = false
- }
- }
- }
-}
-
-private const val SLIM_TESTS_PROPERTY = "slimTests"
diff --git a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/signing/AppSigning.kt b/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/signing/AppSigning.kt
deleted file mode 100644
index 4b5c7130..00000000
--- a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/signing/AppSigning.kt
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-package app.passwordstore.gradle.signing
-
-import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
-import java.util.Properties
-import org.gradle.api.Project
-import org.gradle.kotlin.dsl.configure
-
-private const val KEYSTORE_CONFIG_PATH = "keystore.properties"
-
-/** Configure signing for all build types. */
-@Suppress("UnstableApiUsage")
-internal fun Project.configureBuildSigning() {
- val keystoreConfigFile = rootProject.layout.projectDirectory.file(KEYSTORE_CONFIG_PATH)
- if (keystoreConfigFile.asFile.exists()) {
- extensions.configure<BaseAppModuleExtension> {
- val contents = providers.fileContents(keystoreConfigFile).asText
- val keystoreProperties = Properties()
- keystoreProperties.load(contents.get().byteInputStream())
- signingConfigs {
- register("release") {
- keyAlias = keystoreProperties["keyAlias"] as String
- keyPassword = keystoreProperties["keyPassword"] as String
- storeFile = rootProject.file(keystoreProperties["storeFile"] as String)
- storePassword = keystoreProperties["storePassword"] as String
- }
- }
- val signingConfig = signingConfigs.getByName("release")
- buildTypes.all { setSigningConfig(signingConfig) }
- }
- }
-}
diff --git a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/snapshot/SnapshotExtension.kt b/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/snapshot/SnapshotExtension.kt
deleted file mode 100644
index 191620d1..00000000
--- a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/snapshot/SnapshotExtension.kt
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-package app.passwordstore.gradle.snapshot
-
-abstract class SnapshotExtension {
- abstract var snapshot: Boolean
-}
diff --git a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/versioning/Constants.kt b/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/versioning/Constants.kt
deleted file mode 100644
index 52746c37..00000000
--- a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/versioning/Constants.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * Copyright © 2014-2022 The Android Password Store Authors. All Rights Reserved.
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-package app.passwordstore.gradle.versioning
-
-const val VERSIONING_PROP_FILE = "version.properties"
-const val VERSIONING_PROP_VERSION_NAME = "versioning-plugin.versionName"
-const val VERSIONING_PROP_VERSION_CODE = "versioning-plugin.versionCode"
-const val VERSIONING_PROP_COMMENT =
- """#
-# This file was automatically generated by 'versioning-plugin'. DO NOT EDIT MANUALLY.
-#"""
diff --git a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/versioning/VersioningPlugin.kt b/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/versioning/VersioningPlugin.kt
deleted file mode 100644
index 5fda1a25..00000000
--- a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/versioning/VersioningPlugin.kt
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-package app.passwordstore.gradle.versioning
-
-import com.android.build.api.variant.ApplicationAndroidComponentsExtension
-import com.android.build.api.variant.VariantOutputConfiguration
-import com.android.build.gradle.internal.plugins.AppPlugin
-import com.vdurmont.semver4j.Semver
-import java.util.Properties
-import java.util.concurrent.atomic.AtomicBoolean
-import org.gradle.api.Plugin
-import org.gradle.api.Project
-import org.gradle.kotlin.dsl.getByType
-import org.gradle.kotlin.dsl.register
-import org.gradle.kotlin.dsl.withType
-
-/**
- * A Gradle [Plugin] that takes a [Project] with the [AppPlugin] applied and dynamically sets the
- * versionCode and versionName properties based on values read from a [VERSIONING_PROP_FILE] file in
- * the [Project.getBuildDir] directory. It also adds Gradle tasks to bump the major, minor, and
- * patch versions along with one to prepare the next snapshot.
- */
-@Suppress("Unused")
-class VersioningPlugin : Plugin<Project> {
-
- override fun apply(project: Project) {
- with(project) {
- val androidAppPluginApplied = AtomicBoolean(false)
- val propFile = layout.projectDirectory.file(VERSIONING_PROP_FILE)
- require(propFile.asFile.exists()) {
- "A 'version.properties' file must exist in the project subdirectory to use this plugin"
- }
- val contents = providers.fileContents(propFile).asText
- val versionProps = Properties().also { it.load(contents.get().byteInputStream()) }
- val versionName =
- requireNotNull(versionProps.getProperty(VERSIONING_PROP_VERSION_NAME)) {
- "version.properties must contain a '$VERSIONING_PROP_VERSION_NAME' property"
- }
- val versionCode =
- requireNotNull(versionProps.getProperty(VERSIONING_PROP_VERSION_CODE).toInt()) {
- "version.properties must contain a '$VERSIONING_PROP_VERSION_CODE' property"
- }
- project.plugins.withType<AppPlugin> {
- androidAppPluginApplied.set(true)
- extensions.getByType<ApplicationAndroidComponentsExtension>().onVariants { variant ->
- val mainOutput =
- variant.outputs.single { it.outputType == VariantOutputConfiguration.OutputType.SINGLE }
- mainOutput.versionName.set(versionName)
- mainOutput.versionCode.set(versionCode)
- }
- }
- val version = Semver(versionName)
- tasks.register<VersioningTask>("clearPreRelease") {
- description = "Remove the pre-release suffix from the version"
- semverString.set(version.withClearedSuffix().toString())
- propertyFile.set(propFile)
- }
- tasks.register<VersioningTask>("bumpMajor") {
- description = "Increment the major version"
- semverString.set(version.withIncMajor().withClearedSuffix().toString())
- propertyFile.set(propFile)
- }
- tasks.register<VersioningTask>("bumpMinor") {
- description = "Increment the minor version"
- semverString.set(version.withIncMinor().withClearedSuffix().toString())
- propertyFile.set(propFile)
- }
- tasks.register<VersioningTask>("bumpPatch") {
- description = "Increment the patch version"
- semverString.set(version.withIncPatch().withClearedSuffix().toString())
- propertyFile.set(propFile)
- }
- tasks.register<VersioningTask>("bumpSnapshot") {
- description = "Increment the minor version and add the `SNAPSHOT` suffix"
- semverString.set(version.withIncMinor().withSuffix("SNAPSHOT").toString())
- propertyFile.set(propFile)
- }
- afterEvaluate {
- check(androidAppPluginApplied.get()) {
- "Plugin 'com.android.application' must be applied to ${project.displayName} to use the Versioning Plugin"
- }
- }
- }
- }
-}
diff --git a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/versioning/VersioningTask.kt b/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/versioning/VersioningTask.kt
deleted file mode 100644
index 7eb19a89..00000000
--- a/build-logic/android-plugins/src/main/kotlin/app/passwordstore/gradle/versioning/VersioningTask.kt
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright © 2014-2022 The Android Password Store Authors. All Rights Reserved.
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-package app.passwordstore.gradle.versioning
-
-import com.vdurmont.semver4j.Semver
-import org.gradle.api.DefaultTask
-import org.gradle.api.file.RegularFileProperty
-import org.gradle.api.provider.Property
-import org.gradle.api.tasks.CacheableTask
-import org.gradle.api.tasks.Input
-import org.gradle.api.tasks.OutputFile
-import org.gradle.api.tasks.TaskAction
-
-@CacheableTask
-abstract class VersioningTask : DefaultTask() {
- @get:Input abstract val semverString: Property<String>
-
- @get:OutputFile abstract val propertyFile: RegularFileProperty
-
- /** Generate the Android 'versionCode' property */
- private fun Semver.androidCode(): Int {
- return major * 1_00_00 + minor * 1_00 + patch
- }
-
- private fun Semver.toPropFileText(): String {
- val newVersionCode = androidCode()
- val newVersionName = toString()
- return buildString {
- appendLine(VERSIONING_PROP_COMMENT)
- append(VERSIONING_PROP_VERSION_CODE)
- append('=')
- appendLine(newVersionCode)
- append(VERSIONING_PROP_VERSION_NAME)
- append('=')
- appendLine(newVersionName)
- }
- }
-
- override fun getGroup(): String {
- return "versioning"
- }
-
- @TaskAction
- fun execute() {
- propertyFile.get().asFile.writeText(Semver(semverString.get()).toPropFileText())
- }
-}