Is there a way to get javadocs jar as part of dependency download


(Peter Crosbie) #1

Apologies for such a newbe question that is undoubtedly documented but unfortunately I can’t find.

When i use the following dependency:

dependencies {
     compile 'org.apache.commons:commons-math3:3.0'
}

I get the source and jar but not the javadoc jar. Is there a way to get Gradle to pull the javadoc jar, commons-math3-3.0-javadoc in this case?

I am using Gradle in Eclipse and it would be nice to be able to go look at the javadoc for a dependency without having to separately go download or view online (as I’m often offline).

Many thanks for the help.

— Gradle env info

------------------------------------------------------------ Gradle 1.1 ------------------------------------------------------------

Gradle build time: Tuesday, July 31, 2012 1:24:32 PM UTC Groovy: 1.8.6 Ant: Apache Ant™ version 1.8.4 compiled on May 22 2012 Ivy: 2.2.0 JVM: 1.7.0_05 (Oracle Corporation 23.1-b03) OS: Windows 7 6.1 amd64


(Peter Niederwieser) #2

If you use Gradle’s ‘eclipse’ plugin or the STS Gradle plugin, this will be taken care of automatically.


(Peter Crosbie) #3

Peter

Many thanks. I am using STS with the Gradle plugin and

apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'application'

After adding math3 dependency and refreshing I noted in console that Gradle download source and jar but did not see javadoc jar.

When I select @Javadoc view in STS Eclipse I see basic blurb of class but when I select “Open attached JavaDoc in browswer” I get

The documentation location for 'MersenneTwister' has not been configured. For elements from libraries specify the Javadoc location URL on the properties page of the parent JAR.
('C:\Users\pjc\.gradle\caches\artifacts-13\filestore\org.apache.commons\commons-math3.0\jar\......\commons.math3-3.0.jar')

(Peter Niederwieser) #4

Works fine for me. Did you select “Gradle Project” when importing the project into the IDE? Also make sure you use latest version of STS and Gradle (also in Eclipse).


(Peter Crosbie) #5

Peter, many thanks for your help. I was using an old version of STS-GG (3.0 milestone) but after downloading latest and attempting the the following experiment I still have the same problem - no javadoc jar is being downloaded with the jar and source jar.

Here are the details.

I downloaded and installed latest version of STS-GG 3.0 Rel

Groovy/Grails Tool Suite
   Version: 3.0.0.RELEASE
Build Id: 201208091018

I checked Gradle version as 1.1, the latest

------------------------------------------------------------
Gradle 1.1
------------------------------------------------------------
  Gradle build time: Tuesday, July 31, 2012 1:24:32 PM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.7.0_05 (Oracle Corporation 23.1-b03)
OS: Windows 7 6.1 amd64

I deleted the .gradle folder to remove all old cache data from local machine.

I created a new Gradle project from the New menu in STS-GG 3.0 Rel, picked Quick Start Java project. I added a math3 dependency to the default collections dependency for good measure. Here is the gradle.build file for the new project:

apply plugin: 'java'
apply plugin: 'eclipse'
  sourceCompatibility = 1.5
version = '1.0'
jar {
    manifest {
        attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version
    }
}
  repositories {
    mavenCentral()
}
  dependencies {
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    testCompile group: 'junit', name: 'junit', version: '4.+'
    //apache commons lang (Random)
 compile 'org.apache.commons:commons-math3:3.0'
}
  test {
    systemProperties 'property': 'value'
}
  uploadArchives {
    repositories {
       flatDir {
           dirs 'repos'
       }
    }
}

I ran update dependencies from Gradle menu in STS-GG. Here is the console output from the dependency update for the above gradle.build with no local cache at all (deleted .gradle directory):

Download http://repo1.maven.org/maven2/org/apache/commons/commons-math3/3.0/commons-math3-3.0.pom
Download http://repo1.maven.org/maven2/org/apache/commons/commons-parent/23/commons-parent-23.pom
Download http://repo1.maven.org/maven2/junit/junit/4.10/junit-4.10.pom
Download http://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.pom
Download http://repo1.maven.org/maven2/org/hamcrest/hamcrest-parent/1.1/hamcrest-parent-1.1.pom
Download http://repo1.maven.org/maven2/org/apache/commons/commons-math3/3.0/commons-math3-3.0-sources.jar
Download http://repo1.maven.org/maven2/commons-collections/commons-collections/3.2/commons-collections-3.2-sources.jar
Download http://repo1.maven.org/maven2/junit/junit/4.10/junit-4.10-sources.jar
Download http://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar
Download http://repo1.maven.org/maven2/commons-collections/commons-collections/3.2/commons-collections-3.2.jar
Download http://repo1.maven.org/maven2/org/apache/commons/commons-math3/3.0/commons-math3-3.0.jar
Download http://repo1.maven.org/maven2/junit/junit/4.10/junit-4.10.jar
Download http://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar
  BUILD SUCCESSFUL
  Total time: 1 mins 52.55 secs

(Peter Niederwieser) #6

Can you double-check that the STS plugin really uses Gradle 1.1? Preferences -> Gradle -> Gradle Distribution


(Peter Niederwieser) #7

This should solve the problem:

eclipse.classpath.downloadJavadoc = true // defaults to 'false'

Now “Refresh Dependencies” will download the Javadoc.


(Peter Crosbie) #8

There is no entry for Gradle Distribution under Preferences->Gradle in my STS-GG 3.0Rel installation. I have only:

Preferences->Gradle->Arguments Preferences->Gradle->WTP


(Peter Niederwieser) #9

It’s on the Preferences->Gradle screen.


(Peter Crosbie) #10

Yes, quite right. The Gradle Distribution is set to “Use Gradle wrapper’s default”. I am not sure where to check that but in the .gradle/wrapper/dists folder there is gradle-1.0-bin folder so presumably STS-GG is using 1.0 not 1.1. This gradle-1.0-bin must have been installed by eclipse STS-GG-3.0Rel because I deleted .gradle directory as part of the clean up above to test this issue.


(Peter Crosbie) #11

Should I point the STS Gradle Distrubtion to my 1.1 installation instead of using wrapper default?


(Peter Crosbie) #12

This worked like a charm (even though Gradle 1.0 version being used by STS-GG-3.0Rel as noted in comment below.) Many thanks


(Peter Niederwieser) #13

If your project is wrapper-enabled, then STS will also use the wrapper, and you won’t have to change anything. Sometimes I’ve see STS jump back to a fixed Gradle version though, in which case I had to set it back to use the wrapper.


(Peter Crosbie) #14

The .gradle/wrapper/dists contains “gradle-1.0-bin” which is presumably gradle 1.0. How do I get the wrapper to use 1.1?


(Peter Niederwieser) #15

Edit ‘gradle/gradle-wrapper.properties’ in your project (this is the default location).


(Peter Crosbie) #16

Sorry to be such a pain but can’t find this. What file is this gradle/gradle-wrapper.properties in?


(Peter Crosbie) #17

I see this now after I run a wrapper task and it creates the gradle dir in project directory with gradle/wrapper/gradle-wrapper.properties file. The STS Gradle extension now appears to refer to the gradle-wrapper.properties file and runs gradle 1.1. Is it preferred practice even in STS to run wrapper task to create wrapper gradle directory and properties file? Even if preferred it seems STS Gradle extension should use latest available version or Gradle or at least provide a way to change it without requiring separate wrapper task step?

In any case, many thanks for all your time and help.


(Peter Niederwieser) #18

As I said, you can manually set a Gradle distribution in Preferences->Gradle. In that case you have to download Gradle yourself though. And if your projects use different Gradle versions, you’ll have to manually switch forth and back in Eclipse.