I am building a project with gradle using java plugin and I want also to build javadoc using doclava doclet
Here is the relevant part of the module's build.gradle
apply plugin: 'java'
javadoc {
source = sourceSets.main.allJava
...
exclude "com/mobaires/sdk/api/debug/**"
options.windowTitle = "SDK"
options.docTitle = "SDK"
options.doclet = "com.google.doclava.Doclava"
options.docletpath = [file("libs/doclava-1.0.5.jar")]
}
When I run ./gradlew javadoc I get this error
16:24:46.030 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :javadoc FAILED
16:24:46.035 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[main,5,main]] finished, busy: 0.695 secs, idle: 0.0040 secs
16:24:46.044 [ERROR] [org.gradle.BuildExceptionReporter]
16:24:46.045 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
16:24:46.045 [ERROR] [org.gradle.BuildExceptionReporter]
16:24:46.046 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
16:24:46.046 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':javadoc'.
16:24:46.047 [ERROR] [org.gradle.BuildExceptionReporter] > Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '.../build/tmp/javadoc/javadoc.options'
16:24:46.048 [ERROR] [org.gradle.BuildExceptionReporter]
16:24:46.048 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
16:24:46.049 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.
16:24:46.055 [LIFECYCLE] [org.gradle.BuildResultLogger]
16:24:46.058 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
16:24:46.059 [LIFECYCLE] [org.gradle.BuildResultLogger]
16:24:46.060 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 9.297 secs
Could anybody make it work doclava with Gradle?
After taking a look to the javadoc.options that is mentioned in the error log it says
-classpath '... all the classpath here ...'
-d '.../build/docs/javadoc'
-doclet 'com.google.doclava.Doclava'
-docletpath '../libs/doclava-1.0.5.jar'
-doctitle 'XXXX'
-quiet
-windowtitle 'XXXX'
'... classes to get javadoc'
The problem is that gradle is passing doctitle and windowtitle as arguments to javadoc command which are NOT supported by doclava doclet.
Diving into org.gradle.api.tasks.javadoc.Javadoc code I found a workaround that worked. I have simply added title = null to the javadoc task in build.gradle file
javadoc {
source = sourceSets.main.allJava
...
exclude "com/mobaires/sdk/api/debug/**"
title = null
options.doclet = "com.google.doclava.Doclava"
options.docletpath = [file("libs/doclava-1.0.5.jar")]
}
I hope it helps others :)