From ad7e8bab6f51a49d6ea8f465d35d1ea55c048082 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Wed, 21 Mar 2018 08:55:12 -0400 Subject: [PATCH] Revive build Javadocs on JDK 10 and workaround bug (#29173) This commit reenables the Javadoc tasks on JDK 10. To reenable these tasks, we have to workaround a bug in JDK 10 which trips on some deeply nested anonymous classes that we have in the codebase (and are fine as-is, this is not a problem with this code). The workaround is to remove the compiled classes from the classpath. This has been reported upstream and the workaround was suggested there (see the code comment). --- .../org/elasticsearch/gradle/BuildPlugin.groovy | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 6043ce21090..5eb82c12616 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -475,14 +475,18 @@ class BuildPlugin implements Plugin { } static void configureJavadoc(Project project) { - project.tasks.withType(Javadoc) { - executable = new File(project.compilerJavaHome, 'bin/javadoc') + // remove compiled classes from the Javadoc classpath: http://mail.openjdk.java.net/pipermail/javadoc-dev/2018-January/000400.html + final List classes = new ArrayList<>() + project.tasks.withType(JavaCompile) { javaCompile -> + classes.add(javaCompile.destinationDir) + } + project.tasks.withType(Javadoc) { javadoc -> + javadoc.executable = new File(project.compilerJavaHome, 'bin/javadoc') + javadoc.classpath = javadoc.getClasspath().filter { f -> + return classes.contains(f) == false + } } configureJavadocJar(project) - if (project.compilerJavaVersion == JavaVersion.VERSION_1_10) { - project.tasks.withType(Javadoc) { it.enabled = false } - project.tasks.getByName('javadocJar').each { it.enabled = false } - } } /** Adds a javadocJar task to generate a jar containing javadocs. */