Last Updated: February 25, 2016
·
6.382K
· gschueler

Aggregate Javadoc in multiproject Gradle builds

Here's a brief solution for how to use Gradle to generate all javadoc for a multiproject java build.

Add this to your top-level build.gradle:

apply plugin 'java'
def exportedProjects= [
        ":top-lib",
        ":sub:sub-api",
        ":sub:sub-lib1",
        ":sub:sub-lib2",
        ":sub:sub-lib3"
]

task alljavadoc(type: Javadoc) {
    source exportedProjects.collect { project(it).sourceSets.main.allJava }
    classpath = files(exportedProjects.collect { project(it).sourceSets.main.compileClasspath })
    destinationDir = file("${buildDir}/docs/javadoc")
}

Then run:

gradle alljavadoc

1 Response
Add your response

Recently I addes the lines to my gradle.build but it doesnt work
Im using classpath 'com.android.tools.build:gradle:1.2.3'

over 1 year ago ·