gradlejavadocinheritdoc

How to accomplish inheriting Javadoc comments from JDK with Gradle Javadoc task?


I want my Javadoc to inherit comments from standard JDK classes. For this, I need to add JDK sources to -sourcepath javadoc option. Not to generate documentation for JDK classes themselves, I would specify packages via -packagenames or -subpackages javadoc options, but Javadoc Gradle task doesn't support them.


Solution

  • Well, this appeared to be pretty easy

    javadoc {
        configure((CoreJavadocOptions) getOptions()) {
            addStringOption('sourcepath', project.hasProperty('jdkSrc') ? jdkSrc :
                "$System.env.JAVA_HOME/src")
        }
    }