From 099e703834e8ace6eb4cc1b3e447677c5219a278 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sun, 21 Jun 2020 02:43:32 -0700 Subject: [PATCH] Build compatible bytecode with newer JDKs Fix #2898, close #2899 --- build.gradle | 10 ++++++++++ gradle/wrapper/gradle-wrapper.properties | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ee0599571..04ef40501 100644 --- a/build.gradle +++ b/build.gradle @@ -40,6 +40,16 @@ subprojects { maven { url "https://jitpack.io" } maven { url "http://oss.sonatype.org/content/repositories/snapshots" } } + + if (getPlugins().hasPlugin('java')) { + tasks.withType(JavaCompile) { + // If building with JDK 9+, we need additional flags to generate compatible bytecode + if (JavaVersion.current() > JavaVersion.VERSION_1_8) { + options.compilerArgs += ['--release', '8'] + } + } + } + afterEvaluate { module -> if (getPlugins().hasPlugin('com.android.library') || getPlugins().hasPlugin('com.android.application')) { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 622ab64a3..d4f747c9b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Sat Jun 20 05:36:13 PDT 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip