When using the ‘war’ plugin and the ‘eclipse-wtp’ plugin, Gradle will automatically attach the Web App Libraries container (‘org.eclipse.jst.j2ee.internal.web.container’) as of 1.0-rc-1 per GRADLE-1974.
The dependencies in the ‘.classpath’ do list their source attachments as I would expect. However, because the web libraries container is turned on it shadows the .classpath entries and prevents the source from being attached. Per the discussion in GRADLE-2123, the container stores it’s source attachment in the Eclipse workspace, which isn’t (and shouldn’t be) reachable from Gradle.
However, I don’t buy the reason for GRADLE-1974 adding that container as a default. The only benefit it provides is support for JARs manually included in WEB-INF/lib, which seems like a bad practice in the first place. Trading that source attachments for that benefit feels like a raw deal.
Thanks for reporting this issue. If I understand the problem correctly the sources are not correctly configured by default when eclipse-wtp is applied? E.g. it’s not possible to navigate the source code conveniently from the IDE unless web container is removed?
The sources are correctly configured, if you look at the .classpath file. However, the presence of the Web App Libraries container seems to take precendence over any of the JARs that are both destined for WEB-INF/lib and part of the .classpath. In these cases, they only show up under the container, which doesn’t respect the source attachments from the .classpath.
I’m still getting this issue with Gradle 1.12 and Eclipse Kepler.
I think the issue here is simply that Gradle adds the Web App Libraries container before the other JARs in .classpath. As I’ve played around with Eclipse, it seems to always add the Web App Libraries container last.