There doesn’t seem to be any option for the javadoc task to fail on warnings. Would it be possible to add a flag for this?
There was a workaround using import org.gradle.logging.internal.OutputEventListener that checked for warnings in the output but that broke after an upgrade to Gradle 2.14 (I’m aware of the internal part of the package name).
I’ve found that the class has moved to org.gradle.internal.logging.events and updated the imports, which works but it is still bad to depend on internal stuff. Will there be a publicly available way to do this kind of thing? I.e. doing this without depending on internal classes:
There is a non-standard hidden javadoc option -Xwerror available on all supported Java releases. Thus you could simply do something like this:
if (JavaVersion.current().isJava8Compatible()) {
tasks.withType(Javadoc) {
// The '-quiet' as second argument is actually a hack,
// since the one paramater addStringOption doesn't seem to
// work, we extra add '-quiet', which is added anyway by
// gradle. See https://github.com/gradle/gradle/issues/2354
// See JDK-8200363 (https://bugs.openjdk.java.net/browse/JDK-8200363)
// for information about the -Xwerror option.
options.addStringOption('Xwerror', '-quiet')
}
}
A feature request for an official ‘-Werror’ for javadoc is tracked as JDK-8200363.