Include local javadoc with gradle


(Kasper Sørensen) #1

Hi there,
I am trying to figure out a way to show javadoc from a local .jar in my project, so I can see the documentation in intelliJ (and possible also NetBeans).

My build.gradle contains the following to include the local jars:

dependencies {
    compile fileTree(dir: "./src/libs/", includes: ['*.jar'])
}

and in the libs folder is three .jar files (compiled java, sources and javadoc) all for the same project.

What I cannot figure out it how get intelliJ to read the javadoc and show that. I made a small task with

task listJars {
    configurations.compile.each { File file -> println file.name }
}

to confirm that all the .jar files are included, which they are. The task outputs:

PickRandomStudent-1.0-javadoc.jar
PickRandomStudent-1.0-sources.jar
PickRandomStudent-1.0.jar

The -javadoc.jar was created in another project with the javadoc task.

I also have

apply plugin: 'idea'
idea {
    module {
        downloadJavadoc = true
    }
}

which is not really helping me in this case

Hope you guys can help!
/Kasper


Put jar file to cache manually
(uklance) #2

The simplest way to achieve this is layout the jars in a maven style directory layout.

Eg:

mavenRepo/group/PickRandomStudent/1.0/PickRandomStudent-1.0-javadoc.jar
mavenRepo/group/PickRandomStudent/1.0/PickRandomStudent-1.0-sources.jar
mavenRepo/group/PickRandomStudent/1.0/PickRandomStudent-1.0.jar

You can then reference the dependency in your build

repositories {
   maven {
      url file('mavenRepo') 
    } 
} 
dependencies {
   compile 'group:PickRandomStudent:1.0'
}

This has the added benefit that the jars can now properly participate in Gradle’s dependency resolution process


(Kasper Sørensen) #3

Ah yes! Thank you very much @Lance !