Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to tell Gradle to include dependencies Javadocs in generated Javadocs?

I have a Java project that I am managing with Gradle. Such project will be composed by multiple small libraries, which are developed independently one another, and a "leaf" project whose goal is just to depend on the latest stable version of each library, package everything in a fat Jar and provide aggregated documentation.

Each library will be uploaded as a separate artifact on Maven Central.

In order to test the feasibility of such configuration, I have written a very simple project which depends on GNU Trove4j. I'd like to be able to generate a Javadoc for this project that includes both my source code's and Trove4j's code, but so far I have had no success.

My idea would be to import dependencies' sources from Central as part of Gradle's sourceSet, but I have no idea on how to do it.

like image 943
Danilo Pianini Avatar asked Jan 26 '15 11:01

Danilo Pianini


1 Answers

One way to accomplish this would be to add all the dependencies you want documented to a separate configuration that you then add to the javadoc task. Here is a quick example with a couple of simple libraries:

configurations {
    doc {
        transitive false
    }
}

dependencies {
    doc 'com.google.code.gson:gson:2.3.1:sources'
    doc 'commons-collections:commons-collections:3.2.1:sources'
}

javadoc {
    source configurations.doc.collect { zipTree(it) }
    include '**/*.java'
    options.addStringOption('Xdoclint:none', '-quiet')
}
like image 144
Mark Vieira Avatar answered Oct 11 '22 19:10

Mark Vieira