Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle does not generate Javadocs

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?

like image 503
sparkonhdfs Avatar asked Jan 18 '14 20:01

sparkonhdfs


2 Answers

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/*
like image 182
tintin Avatar answered Oct 08 '22 05:10

tintin


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.

like image 28
sver Avatar answered Oct 08 '22 03:10

sver