Best approach Gradle multi-module project: generate just one global javadoc

Here’s a version I use that is smart enough to know what plugins are applied:

task aggregatedJavadocs(type: Javadoc, description: 'Generate javadocs from all child projects as if it was a single project', group: 'Documentation') {
	destinationDir = file("$buildDir/docs/javadoc")
	title = "$project.name $version API"
	options.author true
	options.links 'http://docs.spring.io/spring/docs/4.3.x/javadoc-api/', 'http://docs.oracle.com/javase/8/docs/api/', 'http://docs.spring.io/spring-ws/docs/2.3.0.RELEASE/api/', 'http://docs.spring.io/spring-security/site/docs/4.0.4.RELEASE/apidocs/'
	options.addStringOption 'Xdoclint:none', '-quiet'
	
	subprojects.each { proj ->
		proj.tasks.withType(Javadoc).each { javadocTask ->
			source += javadocTask.source
			classpath += javadocTask.classpath
			excludes += javadocTask.excludes
			includes += javadocTask.includes
		}
	}
}
3 Likes

Using @eric_deandrea 's version I got an exception:

package javax.portlet does not exist

which has resolved by adding the following code to the task:

options.addStringOption("sourcepath", "")

Google did not get me the correct answer, hope this will help others.