Forcing a module version has no effect on generated org.eclipse.wst.common.component

I have a multi-project build some projects that depend on hibernate-core 3.6.8-Final, which in turn depends on commons-collections 3.1.

I overrode this transitive dependency with the following in all java projects:

configurations {
 all {
  resolutionStrategy.force "commons-collections:commons-collections:3.2.1"

This works fine for all plugins (java, tomcat, war), though it fails to be applied in the case of the eclipse-wtp plugin. The original 3.1 jar is referenced in the generated .settings/org.eclipse.wst.common.component as a dependent-module instead of version 3.2.1.

Thanks for any help!


Did you do a ‘cleanEclipse’?


This reproduces the problem:

apply plugin: "war"
apply plugin: "eclipse-wtp"
  repositories {
  dependencies {
  compile "org.hibernate:hibernate-core:3.6.8.Final"
  configurations {
    all {
        resolutionStrategy.force "commons-collections:commons-collections:3.2.1"

Creating a JIRA issue.

Thanks Peter!

I have another example that is quite probably related. Excludes by configuration don’t work either with eclipse-wtp (using gradle version 1.2). For excludes by dependency (see commented lines below) eclipse-wtp behaves as expected.

With SpringSource inlining a class-incompatible spring-asm into spring-core with version 3.2.0.M2 pretty soon there might be a good amount of gradle-users interested in this:

apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'war'
  repositories {
  configurations {
        runtime.exclude module:'spring-asm'
  dependencies {
       ('org.springframework:spring-beans:3.1.2.RELEASE') {
            exclude module:'spring-asm'

All excludes in this example have an effect on .classpath. Only the commented exclude has an effect on .settings/org.eclipse.wst.common.component.

I dug into gradle sources a bit, and - with close to zero knowledge about the internal matters of gradle -

this is what seems to fix the problem that eclipse-wtp ignores excludes by configuration.

@Peter: This does not seem to be the solution to GRADLE-2496, although it fixes my excluded dependencies issue. What is the correct way to get my concern/possible solution into issue tracking?

From d92af380146e34af1781b78a15770032708a88ed Mon Sep 17 00:00:00 2001
From: illusioni <>
Date: Sat, 6 Oct 2012 00:37:25 +0200
Subject: [PATCH] With little knowledge about the internal matters of gradle -
 this is what seems to fix the problem that eclipse-wtp
 ignores excludes by configuration
  9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
  diff --git a/subprojects/ide/src/main/groovy/org/gradle/plugins/ide/eclipse/model/internal/WtpComponentFactory.groovy b/subprojects/ide/src/main/groovy/org/gradle/plugins/ide/eclipse/model/internal/WtpComponentFactory.groovy
index d1ff2e8..32b7c7a 100644
--- a/subprojects/ide/src/main/groovy/org/gradle/plugins/ide/eclipse/model/internal/WtpComponentFactory.groovy
+++ b/subprojects/ide/src/main/groovy/org/gradle/plugins/ide/eclipse/model/internal/WtpComponentFactory.groovy
@@ -16,7 +16,6 @@
 package org.gradle.plugins.ide.eclipse.model.internal
    import org.gradle.api.artifacts.Configuration
-import org.gradle.api.artifacts.Dependency
 import org.gradle.api.artifacts.ExternalDependency
 import org.gradle.api.artifacts.SelfResolvingDependency
 import org.gradle.plugins.ide.eclipse.EclipsePlugin
@@ -24,6 +23,8 @@ import org.gradle.plugins.ide.eclipse.model.EclipseWtpComponent
 import org.gradle.plugins.ide.eclipse.model.WbDependentModule
 import org.gradle.plugins.ide.eclipse.model.WbResource
 import org.gradle.plugins.ide.eclipse.model.WtpComponent
+import org.gradle.plugins.ide.internal.IdeDependenciesExtractor
+import org.gradle.plugins.ide.internal.IdeDependenciesExtractor.IdeRepoFileDependency
  * @author Hans Dockter
@@ -89,7 +90,11 @@ class WtpComponentFactory {
         Set declaredDependencies = getDependencies(plusConfigurations, minusConfigurations,
                 { it instanceof ExternalDependency})
      Set libFiles = wtp.project.configurations.detachedConfiguration((declaredDependencies as Dependency[])).files +
      //Just like in ClasspathFactory this considers excludes by configuration:
      List<IdeRepoFileDependency> deps = new IdeDependenciesExtractor().extractRepoFileDependencies(wtp.project.configurations, plusConfigurations, minusConfigurations, false, false)
      Set libFiles = deps.collect { IdeRepoFileDependency dep -> dep.file }
      libFiles = libFiles +
                 getSelfResolvingFiles(getDependencies(plusConfigurations, minusConfigurations,
                         { it instanceof SelfResolvingDependency && !(it instanceof org.gradle.api.artifacts.ProjectDependency)}))

Hey, Thanks for trying to debug the issue. Do you mind sending a pull request (the above patch does not seem to be correct) for this bugfix?

One other potential workaround is using eclipse tasks’ whenMerged hook to manipulate the final list of the classpath entries.

Hope that helps!

OK, the pull request is sent:

I apologize for mixing this problem with David’s issue. I thought using the common IdeDependenciesExtractor in WtpComponentFactory would take care of both, forced dependencies and excludes by configuration. (But it only solved the latter.)


Is there some kind of workaround for this problem that I could apply to my build files until this is fixed in eclipse-wtp? I was so happy when Gradle 1.4 added the new dependency resolve rules which allows something like this.

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if ( == 'org.springframework') {
            details.useVersion '3.2.0.RELEASE'

Unfortunately eclipse-wtp completly ignores those rules which makes them kinda useless to me.

There’s no easy workaround I’m afraid. I’ll raise this ticket to the team.

You can try with the whenMerged / withXml hooks ( to manipulate the component content.

I’ve created new ticket for it: GRADLE-2653

We already have a pull request and it should get applied soon.

This problem is now fixed in master and should be released with 1.5.