aboutsummaryrefslogtreecommitdiff
path: root/buildSrc/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'buildSrc/src/main')
-rw-r--r--buildSrc/src/main/java/BaseProjectConfig.kt83
-rw-r--r--buildSrc/src/main/java/BinaryCompatibilityValidator.kt16
-rw-r--r--buildSrc/src/main/java/Dependencies.kt15
-rw-r--r--buildSrc/src/main/java/KotlinCompilerArgs.kt8
-rw-r--r--buildSrc/src/main/java/PasswordStorePlugin.kt44
5 files changed, 155 insertions, 11 deletions
diff --git a/buildSrc/src/main/java/BaseProjectConfig.kt b/buildSrc/src/main/java/BaseProjectConfig.kt
new file mode 100644
index 00000000..3b2a3f3b
--- /dev/null
+++ b/buildSrc/src/main/java/BaseProjectConfig.kt
@@ -0,0 +1,83 @@
+/*
+ * Copyright © 2014-2020 The Android Password Store Authors. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+import com.android.build.gradle.TestedExtension
+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
+import org.gradle.kotlin.dsl.repositories
+import org.gradle.kotlin.dsl.withType
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+
+/**
+ * Configure root project.
+ * Note that classpath dependencies still need to be defined in the `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 = "6.7"
+ distributionType = Wrapper.DistributionType.ALL
+ distributionSha256Sum = "0080de8491f0918e4f529a6db6820fa0b9e818ee2386117f4394f95feb1d5583"
+ }
+ configureBinaryCompatibilityValidator()
+}
+
+/**
+ * Configure all projects including the root project
+ */
+internal fun Project.configureForAllProjects() {
+ repositories {
+ google()
+ jcenter()
+ maven { setUrl("https://jitpack.io") }
+ }
+ tasks.withType<KotlinCompile> {
+ kotlinOptions {
+ jvmTarget = JavaVersion.VERSION_1_8.toString()
+ freeCompilerArgs = freeCompilerArgs + additionalCompilerArgs
+ languageVersion = "1.4"
+ }
+ }
+ tasks.withType<Test> {
+ maxParallelForks = Runtime.getRuntime().availableProcessors() * 2
+ testLogging {
+ events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
+ }
+ }
+}
+
+/**
+ * Apply baseline configurations for all Android projects (Application and Library).
+ */
+@Suppress("UnstableApiUsage")
+internal fun TestedExtension.configureCommonAndroidOptions() {
+ compileSdkVersion(29)
+
+ defaultConfig {
+ minSdkVersion(23)
+ targetSdkVersion(29)
+ }
+
+ packagingOptions {
+ exclude("**/*.version")
+ exclude("**/*.txt")
+ exclude("**/*.kotlin_module")
+ exclude("**/plugin.properties")
+ }
+
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
+ }
+
+ testOptions.animationsDisabled = true
+}
diff --git a/buildSrc/src/main/java/BinaryCompatibilityValidator.kt b/buildSrc/src/main/java/BinaryCompatibilityValidator.kt
new file mode 100644
index 00000000..b622513c
--- /dev/null
+++ b/buildSrc/src/main/java/BinaryCompatibilityValidator.kt
@@ -0,0 +1,16 @@
+/*
+ * Copyright © 2014-2020 The Android Password Store Authors. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+import kotlinx.validation.ApiValidationExtension
+import org.gradle.api.Project
+import org.gradle.kotlin.dsl.configure
+
+internal fun Project.configureBinaryCompatibilityValidator() {
+ extensions.configure<ApiValidationExtension> {
+ ignoredProjects = mutableSetOf(
+ "app"
+ )
+ }
+}
diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt
index 0f8c903d..715ec811 100644
--- a/buildSrc/src/main/java/Dependencies.kt
+++ b/buildSrc/src/main/java/Dependencies.kt
@@ -5,13 +5,6 @@
private const val KOTLIN_VERSION = "1.4.10"
-object Plugins {
-
- const val agp = "com.android.tools.build:gradle:4.0.2"
- const val binaryCompatibilityValidator = "org.jetbrains.kotlinx:binary-compatibility-validator:0.2.3"
- const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION"
-}
-
object Dependencies {
object Kotlin {
object Coroutines {
@@ -28,7 +21,7 @@ object Dependencies {
const val activity_ktx = "androidx.activity:activity-ktx:1.2.0-beta01"
const val annotation = "androidx.annotation:annotation:1.1.0"
- const val autofill = "androidx.autofill:autofill:1.1.0-alpha02"
+ const val autofill = "androidx.autofill:autofill:1.1.0-beta01"
const val appcompat = "androidx.appcompat:appcompat:1.3.0-alpha02"
const val biometric = "androidx.biometric:biometric:1.1.0-beta01"
const val constraint_layout = "androidx.constraintlayout:constraintlayout:2.0.2"
@@ -38,7 +31,7 @@ object Dependencies {
const val lifecycle_common = "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
const val lifecycle_livedata_ktx = "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion"
const val lifecycle_viewmodel_ktx = "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion"
- const val material = "com.google.android.material:material:1.3.0-alpha02"
+ const val material = "com.google.android.material:material:1.3.0-alpha03"
const val preference = "androidx.preference:preference:1.1.1"
const val recycler_view = "androidx.recyclerview:recyclerview:1.2.0-alpha06"
const val recycler_view_selection = "androidx.recyclerview:recyclerview-selection:1.1.0-rc03"
@@ -72,12 +65,12 @@ object Dependencies {
object NonFree {
- const val google_play_auth_api_phone = "com.google.android.gms:play-services-auth-api-phone:17.4.0"
+ const val google_play_auth_api_phone = "com.google.android.gms:play-services-auth-api-phone:17.5.0"
}
object Testing {
- const val junit = "junit:junit:4.13"
+ const val junit = "junit:junit:4.13.1"
const val kotlin_test_junit = "org.jetbrains.kotlin:kotlin-test-junit:$KOTLIN_VERSION"
object AndroidX {
diff --git a/buildSrc/src/main/java/KotlinCompilerArgs.kt b/buildSrc/src/main/java/KotlinCompilerArgs.kt
new file mode 100644
index 00000000..b4931917
--- /dev/null
+++ b/buildSrc/src/main/java/KotlinCompilerArgs.kt
@@ -0,0 +1,8 @@
+/*
+ * Copyright © 2014-2020 The Android Password Store Authors. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+internal val additionalCompilerArgs = listOf(
+ "-Xopt-in=kotlin.RequiresOptIn"
+)
diff --git a/buildSrc/src/main/java/PasswordStorePlugin.kt b/buildSrc/src/main/java/PasswordStorePlugin.kt
new file mode 100644
index 00000000..37a23b02
--- /dev/null
+++ b/buildSrc/src/main/java/PasswordStorePlugin.kt
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2014-2020 The Android Password Store Authors. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+import com.android.build.gradle.TestedExtension
+import com.android.build.gradle.internal.plugins.AppPlugin
+import com.android.build.gradle.internal.plugins.LibraryPlugin
+import org.gradle.api.Plugin
+import org.gradle.api.Project
+import org.gradle.api.plugins.JavaLibraryPlugin
+import org.gradle.api.plugins.JavaPlugin
+import org.gradle.api.tasks.compile.JavaCompile
+import org.gradle.kotlin.dsl.getByType
+import org.gradle.kotlin.dsl.withType
+
+class PasswordStorePlugin : Plugin<Project> {
+
+ override fun apply(project: Project) {
+ project.configureForAllProjects()
+
+ if (project.isRoot) {
+ project.configureForRootProject()
+ }
+
+ project.plugins.all {
+ when (this) {
+ is JavaPlugin,
+ is JavaLibraryPlugin -> {
+ project.tasks.withType<JavaCompile> {
+ options.compilerArgs.add("-Xlint:unchecked")
+ options.isDeprecation = true
+ }
+ }
+ is LibraryPlugin,
+ is AppPlugin -> {
+ project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions()
+ }
+ }
+ }
+ }
+}
+
+private val Project.isRoot get() = this == this.rootProject