From f8040c0ecf1d074640aeae3e9a75b96cc8e2062d Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Mon, 15 Mar 2021 10:19:27 +0100 Subject: [PATCH] LUCENE-9650: errorprone plugin doesn't work on jdk16. A different workaround that keeps the dependency. --- gradle/validation/error-prone.gradle | 34 ++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/gradle/validation/error-prone.gradle b/gradle/validation/error-prone.gradle index edcbaed9fc6..3ed0bf31847 100644 --- a/gradle/validation/error-prone.gradle +++ b/gradle/validation/error-prone.gradle @@ -15,21 +15,37 @@ * limitations under the License. */ -def includeErrorProne = rootProject.runtimeJavaVersion <= JavaVersion.VERSION_15; -if (!includeErrorProne) { - logger.warn("WARNING: errorprone disabled (won't work with JDK ${rootProject.runtimeJavaVersion})") +def skipErrorProne = rootProject.runtimeJavaVersion > JavaVersion.VERSION_15; +if (skipErrorProne) { + configure(rootProject) { + task errorProneSkipped() { + doFirst { + logger.warn("WARNING: errorprone disabled (won't work with JDK ${rootProject.runtimeJavaVersion})") + } + } + } } allprojects { prj -> plugins.withType(JavaPlugin) { - prj.apply plugin: 'net.ltgt.errorprone' + // LUCENE-9650: Errorprone on master/gradle does not work with JDK-16+ + // this is a hack to keep the dependency (so that palantir's version check doesn't complain) + // but don't include the plugin (which fails on JDK16+). + if (skipErrorProne) { + tasks.withType(JavaCompile) { task -> task.dependsOn ":errorProneSkipped" } + configurations { + errorprone + } + dependencies { + errorprone("com.google.errorprone:error_prone_core") + } + } else { + prj.apply plugin: 'net.ltgt.errorprone' - dependencies { - errorprone("com.google.errorprone:error_prone_core") - } + dependencies { + errorprone("com.google.errorprone:error_prone_core") + } - // LUCENE-9650: Errorprone on master/gradle no longer works with JDK-16 - if (includeErrorProne) { tasks.withType(JavaCompile) { task -> options.errorprone.disableWarningsInGeneratedCode = true options.errorprone.errorproneArgs = [