Java 9 Help - javadoc task can't find XML classes


(Scott Palmer) #1

I’m just trying to build my project with Java 9-ea+138. The compileJava task runs successfully, but the javadoc task complains and errors out:

… error: package javax.xml.bind does not exist
import javax.xml.bind.Unmarshaller;
^
… error: cannot find symbol
@XmlRootElement( …

(there are many such issues)

I’m assuming this is something to do with the module system, but I didn’t have to do anything special for the compileJava task to run and my attempts at adding parameters to the javadoc task haven’t helped. I don’t really know precisely what the issue is so I’m stabbing in the dark. I tried:

javadoc {
    options.addStringOption('-add-modules', 'ALL-MODULE-PATH')
}

but that caused the javadoc task to fail with:
error: cannot find module: jdk.management.jfr

I clearly don’t know what I’m doing :-). Can someone please give me a hint?


(Scott Palmer) #2

Well I found a solution, though I still don’t understand why compileJava works without tweaks and javadoc needs this.

javadoc {
    options.addStringOption('-add-modules', 'java.xml.bind')
}

does the trick