Creating documentation
To generate Javadoc documentation, we must use the javadoc
task that is of type org.gradle.api.tasks.javadoc.Javadoc
. The task generates documentation for the Java source files in the main
source set. If we want to generate documentation for the source sets in our project, we must configure the javadoc
task or add an extra javadoc
task to our project.
Note that, in our project, we have an api
and main
source set with the Java source files. If we want to generate documentation for both the source sets, we have to configure the javadoc
task in our project. The source
property of the javadoc
task is, by default, set to sourceSets.main.allJava
. If we add sourceSets.api.allJava
to the source
property, our interface file is also processed by the javadoc
task:
apply plugin: 'java' ... javadoc { source sourceSets.api.allJava } ...
Next, we can run the javadoc
task, and the documentation is generated and put into the build/docs/javadoc
directory:
$ gradle javadoc :compileApiJava...