diff --git a/gradle/documentation/render-javadoc.gradle b/gradle/documentation/render-javadoc.gradle index ff26748fa1e..55f904ee498 100644 --- a/gradle/documentation/render-javadoc.gradle +++ b/gradle/documentation/render-javadoc.gradle @@ -506,12 +506,23 @@ class RenderJavadocTask extends DefaultTask { def outputFile = project.file("${getTemporaryDir()}/javadoc-output.txt") def result + outputFile.withOutputStream { output -> result = project.exec { executable javadocCmd - standardOutput = output - errorOutput = output + // we want to capture both stdout and stderr to the same + // stream but gradle attempts to close these separately + // (it has two independent pumping threads) and it can happen + // that one still tries to write something when the other closed + // the underlying output stream. + def wrapped = new java.io.FilterOutputStream(output) { + public void close() { + // no-op. we close this stream manually. + } + } + standardOutput = wrapped + errorOutput = wrapped args += [ "@${optionsFile}" ] @@ -522,6 +533,8 @@ class RenderJavadocTask extends DefaultTask { ignoreExitValue true } + + logger.lifecycle("Exec returned: ${result}") } if (result.getExitValue() != 0) {