Eclipse can't find the sources when using eclipse-wtp

eclipse

(Kent Tong) #1

I’d like to download the sources of dependences for use in Eclipse. Gradle downloads the sources just fine. In fact, the source is specified in the .classpath generated. However, eclipse doesn’t seem to find the source. I have to manually select the external path to it. The weird thing is, this action seems to cause no change to any file in the project folder, so I can’t track what makes the difference and how to fix it.

Below is my build.gradle file:

plugins {
  id 'java'
  id 'application'
  id 'eclipse'
  id 'war'
  id 'eclipse-wtp'  
}

eclipse {
    classpath {
       downloadSources=true
    }
}
   
repositories {
  jcenter()
}

dependencies {
  compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.1'
  compile group: 'joda-time', name: 'joda-time', version: '2.9.9'
  providedCompile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
  compile group: 'org.apache.struts', name: 'struts2-core', version: '2.5.14.1'
}

The entry in .classpath is:

<classpathentry sourcepath="/home/kent/.gradle/caches/modules-2/files-2.1/org.apache.struts/struts2-core/2.5.14.1/4ca976c1de5dc2071173c884d9259db114ec3f89/struts2-core-2.5.14.1-sources.jar" kind="lib" path="/home/kent/.gradle/caches/modules-2/files-2.1/org.apache.struts/struts2-core/2.5.14.1/ef575752783dc8f22fade1a3b13330274e7d7f23/struts2-core-2.5.14.1.jar">
    <attributes>
            <attribute name="org.eclipse.jst.component.nondependency" value=""/>
    </attributes>

Any idea how to make it work automatically?

Thanks in advance