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).
This commit is contained in:
Jason Tedor 2018-03-21 08:55:12 -04:00 committed by GitHub
parent 93ff973afc
commit ad7e8bab6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 6 deletions

View File

@ -475,14 +475,18 @@ class BuildPlugin implements Plugin<Project> {
}
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<File> 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. */