I am writing a build file with Gradle to do Java build operations. However, Gradle does not generate Javadocs for my project. According to Gradle.org's documentation, to implement a Javadocs task in Gradle, the source and classpath have to be specified.
apply plugin: 'java'
javadoc {
source = sourceSets.main.allJava
classpath = configurations.compile
}
However, when I run the command gradle javadoc
, or gradle build
, the default folder for javadocs (build\docs) is never created, so no html files are generated for the project. What can I do to fix this?
Seems like your directory structure is is not a standard src/main/java
. If that is the case then you need to specify the include pattern as part of the include closure, something like this:
javadoc {
source = sourceSets.main.allJava
classpath = configurations.compile
}
include **/your/directory/structure/*
You can write a gradle task of type Javadoc to create javadocs like this :
task createJavadocs (type: Javadoc)
{
source = project.android.sourceSets.main.java.srcDirs
options.linkSource true
classpath += project.files(project.android.getBootClasspath().join(File.pathSeparator))
failOnError false
}
To create Javadocs, simply run this task.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With