Improve ktlint and JDK compatibility

This eliminates the need to manually set a JDK version when running ktlintFormat.
This commit is contained in:
Carter Jernigan 2021-11-29 14:10:31 -05:00
parent 53ec7704c2
commit 0c570a2535
2 changed files with 9 additions and 3 deletions

View File

@ -234,8 +234,8 @@ 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. 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.
1. `ktlintFormat` may fail on Java 16 or greater. A temporary workaround is to install an older JDK and explicitly set the JDK version when executing the task. For example: `./gradlew ktlintFormat -Dorg.gradle.java.home=/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home`
1. Some JDK distributions don't offer older versions for M1 Macs. [Azul Zulu](https://www.azul.com/downloads/?os=macos&architecture=arm-64-bit&package=jdk) does offer JDK 11 and JDK 15 for M1 Macs, which should be compatible with our builds.

View File

@ -24,6 +24,12 @@ tasks {
}
register("ktlintFormat", org.gradle.api.tasks.JavaExec::class) {
// Workaround for ktlint bug; force to run on an older JDK
// https://github.com/pinterest/ktlint/issues/1274
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(JavaVersion.VERSION_11.majorVersion))
})
description = "Apply code style formatting with ktlint"
classpath = ktlint
mainClass.set("com.pinterest.ktlint.Main")