Skip to content

Commit ad7e8ba

Browse files
authored
Revive build Javadocs on JDK 10 and workaround bug (elastic#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).
1 parent 93ff973 commit ad7e8ba

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

+10-6
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,18 @@ class BuildPlugin implements Plugin<Project> {
475475
}
476476

477477
static void configureJavadoc(Project project) {
478-
project.tasks.withType(Javadoc) {
479-
executable = new File(project.compilerJavaHome, 'bin/javadoc')
478+
// remove compiled classes from the Javadoc classpath: http://mail.openjdk.java.net/pipermail/javadoc-dev/2018-January/000400.html
479+
final List<File> classes = new ArrayList<>()
480+
project.tasks.withType(JavaCompile) { javaCompile ->
481+
classes.add(javaCompile.destinationDir)
480482
}
481-
configureJavadocJar(project)
482-
if (project.compilerJavaVersion == JavaVersion.VERSION_1_10) {
483-
project.tasks.withType(Javadoc) { it.enabled = false }
484-
project.tasks.getByName('javadocJar').each { it.enabled = false }
483+
project.tasks.withType(Javadoc) { javadoc ->
484+
javadoc.executable = new File(project.compilerJavaHome, 'bin/javadoc')
485+
javadoc.classpath = javadoc.getClasspath().filter { f ->
486+
return classes.contains(f) == false
487+
}
485488
}
489+
configureJavadocJar(project)
486490
}
487491

488492
/** Adds a javadocJar task to generate a jar containing javadocs. */

0 commit comments

Comments
 (0)