From eb728fe3d86873430d77b7c64900e9645d1ffe20 Mon Sep 17 00:00:00 2001 From: Carter Jernigan Date: Tue, 4 Jan 2022 15:00:51 -0500 Subject: [PATCH] [#330] Use KSP for annotation processing This resolves issues with included builds --- README.md | 4 +--- build.gradle.kts | 1 + gradle.properties | 1 + sdk-lib/build.gradle.kts | 4 ++-- settings.gradle.kts | 3 +++ 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1fa2f63c..85368919 100644 --- a/README.md +++ b/README.md @@ -234,8 +234,6 @@ Publishing instructions for maintainers of this repository can be found in [PUBL [Back to contents](#contents) # Known Issues -1. [#330](https://github.com/zcash/zcash-android-wallet-sdk/issues/330) The SDK will fail to build on Java 16 or later. It is recommended that at least Java 11 is installed. If a newer JDK is needed, Java 15 can also be installed. - 1. Some JDK distributions don't offer older versions for Apple Silicon. [Azul Zulu](https://www.azul.com/downloads/?os=macos&architecture=arm-64-bit&package=jdk) does offer JDK 11 and JDK 15 for Apple Silicon, which should be compatible with our builds. - 1. `ktlintFormat` may fail on Java 16 or greater. As a workaround, the task is run under Java 11. This requires that JDK 11 be installed, even if a newer JDK is also installed. While this is configured to use the Java toolchain API, [toolchain support for Java 11 does not work on Apple Silicon](https://github.com/gradle/gradle/issues/19140) +1. `ktlintFormat` may fail on Java 16 or greater. As a workaround, the task is run under Java 11. This requires that JDK 11 be installed, even if a newer JDK is also installed. While this is configured to use the Java toolchain API, [toolchain support for Java 11 does not work on Apple Silicon](https://github.com/gradle/gradle/issues/19140) 1. During builds, a warning will be printed that says "Unable to detect AGP versions for included builds. All projects in the build should use the same AGP version." This can be safely ignored. The version under build-conventions is the same as the version used elsewhere in the application. 1. Android Studio will warn about the Gradle checksum. This is a [known issue](https://github.com/gradle/gradle/issues/9361) and can be safely ignored. diff --git a/build.gradle.kts b/build.gradle.kts index 005cf6ea..d7fc25a9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,6 +4,7 @@ buildscript { gradlePluginPortal() } dependencies { + classpath(kotlin("gradle-plugin", version = libs.versions.kotlin.get())) classpath(libs.gradle.plugin.android) classpath(libs.gradle.plugin.rust) classpath(libs.gradle.plugin.publish) diff --git a/gradle.properties b/gradle.properties index e5a59eba..f2a9295d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -65,6 +65,7 @@ DETEKT_VERSION=1.18.1 DOKKA_VERSION=1.6.10 GRADLE_VERSIONS_PLUGIN_VERSION=0.38.0 KTLINT_VERSION=0.43.0 +KSP_VERSION=1.6.10-1.0.2 MAVEN_PUBLISH_GRADLE_PLUGIN=0.18.0 OWASP_DEPENDENCY_CHECK_VERSION=6.5.0.1 PROTOBUF_GRADLE_PLUGIN_VERSION=0.8.18 diff --git a/sdk-lib/build.gradle.kts b/sdk-lib/build.gradle.kts index f9c7c599..b1c39d90 100644 --- a/sdk-lib/build.gradle.kts +++ b/sdk-lib/build.gradle.kts @@ -9,7 +9,7 @@ plugins { id("com.android.library") id("zcash.android-build-conventions") kotlin("android") - kotlin("kapt") + id("com.google.devtools.ksp") id("org.jetbrains.kotlin.plugin.allopen") id("org.jetbrains.dokka") id("com.google.protobuf") @@ -170,7 +170,7 @@ dependencies { // Architecture Components: Room implementation(libs.androidx.room.core) implementation(libs.androidx.paging) - kapt(libs.androidx.room.compiler) + ksp(libs.androidx.room.compiler) // Kotlin implementation(libs.kotlin.stdlib) diff --git a/settings.gradle.kts b/settings.gradle.kts index 8c795c43..808e3089 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -12,10 +12,12 @@ pluginManagement { val dokkaVersion = extra["DOKKA_VERSION"].toString() val gradleVersionsPluginVersion = extra["GRADLE_VERSIONS_PLUGIN_VERSION"].toString() val kotlinVersion = extra["KOTLIN_VERSION"].toString() + val kspVersion = extra["KSP_VERSION"].toString() val owaspVersion = extra["OWASP_DEPENDENCY_CHECK_VERSION"].toString() val protobufVersion = extra["PROTOBUF_GRADLE_PLUGIN_VERSION"].toString() id("com.github.ben-manes.versions") version (gradleVersionsPluginVersion) apply (false) + id("com.google.devtools.ksp") version(kspVersion) apply (false) id("com.google.protobuf") version (protobufVersion) apply (false) id("io.gitlab.arturbosch.detekt") version (detektVersion) apply (false) id("org.jetbrains.dokka") version (dokkaVersion) apply (false) @@ -73,6 +75,7 @@ dependencyResolutionManagement { // Standalone versions version("grpc", grpcVersion) version("java", javaVersion) + version("kotlin", kotlinVersion) version("protoc", protocVersion) // Aliases