aboutsummaryrefslogtreecommitdiff
path: root/build-logic/kotlin-plugins/src
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2021-11-29 02:19:27 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2021-12-03 12:59:57 +0530
commit4fb066dff5593a802ac53b681748da549d774f36 (patch)
tree64d0f79b575af8ed3f396c171dc2fcd2dcc53dea /build-logic/kotlin-plugins/src
parent70cdd6179744468ff18c16dc9d131130801fbb5b (diff)
build-logic/kotlin-plugins: add android and kapt plugins
Diffstat (limited to 'build-logic/kotlin-plugins/src')
-rw-r--r--build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.kotlin-android.gradle.kts9
-rw-r--r--build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.kotlin-kapt.gradle.kts45
-rw-r--r--build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.spotless.gradle.kts1
3 files changed, 55 insertions, 0 deletions
diff --git a/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.kotlin-android.gradle.kts b/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.kotlin-android.gradle.kts
new file mode 100644
index 00000000..1c3f1a27
--- /dev/null
+++ b/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.kotlin-android.gradle.kts
@@ -0,0 +1,9 @@
+/*
+ * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+plugins {
+ kotlin("android")
+ id("com.github.android-password-store.kotlin-common")
+}
diff --git a/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.kotlin-kapt.gradle.kts b/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.kotlin-kapt.gradle.kts
new file mode 100644
index 00000000..36642ba4
--- /dev/null
+++ b/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.kotlin-kapt.gradle.kts
@@ -0,0 +1,45 @@
+/*
+ * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+import org.gradle.api.Project
+import org.gradle.kotlin.dsl.configure
+import org.jetbrains.kotlin.gradle.plugin.KaptExtension
+
+plugins {
+ kotlin("android")
+ kotlin("kapt")
+}
+
+afterEvaluate {
+ extensions.configure<KaptExtension> {
+ javacOptions {
+ if (hasDaggerCompilerDependency()) {
+ // https://dagger.dev/dev-guide/compiler-options#fastinit-mode
+ option("-Adagger.fastInit=enabled")
+ // Enable the better, experimental error messages
+ // https://github.com/google/dagger/commit/0d2505a727b54f47b8677f42dd4fc5c1924e37f5
+ option("-Adagger.experimentalDaggerErrorMessages=enabled")
+ // Share test components for when we start leveraging Hilt for tests
+ // https://github.com/google/dagger/releases/tag/dagger-2.34
+ option("-Adagger.hilt.shareTestComponents=true")
+ // KAPT nests errors causing real issues to be suppressed in CI logs
+ option("-Xmaxerrs", 500)
+ // Enables per-module validation for faster error detection
+ // https://github.com/google/dagger/commit/325b516ac6a53d3fc973d247b5231fafda9870a2
+ option("-Adagger.moduleBindingValidation=ERROR")
+ }
+ }
+ }
+}
+// disable kapt tasks for unit tests
+tasks.matching { it.name.startsWith("kapt") && it.name.endsWith("UnitTestKotlin") }.configureEach {
+ enabled = false
+}
+
+fun Project.hasDaggerCompilerDependency(): Boolean {
+ return configurations.any {
+ it.dependencies.any { dependency -> dependency.name == "hilt-compiler" }
+ }
+}
diff --git a/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.spotless.gradle.kts b/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.spotless.gradle.kts
index 83fae3d5..de0c1efd 100644
--- a/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.spotless.gradle.kts
+++ b/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.spotless.gradle.kts
@@ -2,6 +2,7 @@
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
+
plugins { id("com.diffplug.spotless") }
spotless {