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.
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:
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 <klaus@illusioni.de>
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
---
.../model/internal/WtpComponentFactory.groovy
|
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)}))
--
1.7.9.4
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.