Gradle in eclipse is not showing external dependencies sources and java docs in eclipse IDE

Basit picture Basit · Feb 10, 2016 · Viewed 7.5k times · Source

I am new to gradle. I converted one of my maven project to gradle. I installed eclipse gradle plugin. After that I configure my gradle like below

Eclipse Gradle configuration

Here is my build.gradle

apply plugin: 'application' // implicitly apply java and distribution plugin
apply plugin: 'eclipse'

sourceCompatibility = 1.8
targetCompatibility = sourceCompatibility

mainClassName = "com.softech.ls360.integration.BatchImport"

version = '1.0'

repositories {
    mavenCentral()
    mavenLocal()
}

ext {
    log4jGroupId = "org.apache.logging.log4j"
    springFrameworkGroupId = "org.springframework"
    springFrameworkVersion = "4.2.4.RELEASE"
    ....
}

dependencies {
     ['spring-context-support', 'spring-oxm', 'spring-test', 'spring-jms'].each {
        compile "$springFrameworkGroupId:$it:$springFrameworkVersion"
    }
    ...
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.11'
}

task copyJars(type: Copy) {
    ....
}

task copyConfigurationFiles(type: Copy) {
    ....
}

jar {
    ....
}

eclipse {
    classpath {
       downloadSources=true
       downloadJavadoc=true
    }
}

uploadArchives {
    repositories {
       flatDir {
           dirs 'repos'
       }
    }
}

I tried by right cliclking on project --> Gradle --> Refresh Dependencies. Also Refresh sources, refresh all. I saw in the console that eclipse downloaded the sources and jars

Gradle Downloaded Sources

Here is the javadocs screen shot

Gradle Javadocs Sources

If i expand the Gradle dependency and click one of the dependency jars, then it shows the code like

Gradle dependency expand tree

But from the eclipse editor when I click on one of the class then I got screen like this

Right click to see source code

No course code

No source is showning

Why ? Here is my project build path

Project Build path

In maven project it works perfectly fine. It open the source code. I can put breakpoints there. Although I can't modify the code, but at-least for debugging it works perfect.

How can I configure gradle for this situation? I tried by eclipseClean clean. Close the eclipse. Then open and importing the project. But result is same.

Am I missing something in build.gradle ?

Thanks

EDIT: __________________________

Here what I noticed.

Click to see JMS code

I get screen like this

Point to wrong jar

See It is pointing to Spring-context jar instead of spring-jms jar. But when I change it to location, by clicking on External File, where gradle downlaoded sources. It starts show sources

Selecting correct jar

Select correct jar

source starts showing

I don't know why it is behaving like this. May be I did something wrong while setup the project that's why it is behaving like this.

HHmm don't know hwy ?

Thanks

Answer

Dheeraj picture Dheeraj · Apr 18, 2020

It has happened for me couple of times. External dependencies are not being added to the IDE's (Eclipse or Spring tool suite).

To overcome this problem,
1) Close the existing IDE. Do a gradle clean build --refresh-dependencies from command prompt.
2) Next, create a new workspace and freshly IMPORT the project from the eclipse into this newly created workspace.