Using Gradle 1.6,
Sub-Project build.gradle contains
dependencies {
...
compile group:'commons-collections',
name:'commons-collections',
version:'3.2'
...
}
The main project has no direct dependency to commons-collections. Its build.gradle contains
// ----------------------------------------------------------------
// Sub-projects
// ----------------------------------------------------------------
def CSOS
= "csos-trunk"
evaluationDependsOn(":${CSOS}")
// ensure the relevant sub-projects are parsed before this one
// -----------------------------------------------------------------------------
// Build Configurations
// -----------------------------------------------------------------------------
configurations {
// compile is to contain ALL server side compile time dependencies
compile {
transitive = false
}
// gwt contains compile time dependencies (and also runtime) that are exclusively client side only
// any dependencies shared with the "server" should be defined in the "compile" group
gwt {
extendsFrom compile
// gwt contains ALL client side dependencies
transitive = false
// without this line transitive is true
}
...
}
dependencies {
// --------------------------------------------------------------------------------------------------------------------------------------------
// sub projects "compile" dependencies
// --------------------------------------------------------------------------------------------------------------------------------------------
compile project(":${CSOS}").sourceSets.main.output
...
}
// ----------------------------------------------------------------
// File locations
// ----------------------------------------------------------------
def DIR_BUILD_GWT_DEV
= "war"
def DIR_CLASSES
= "${DIR_BUILD_GWT_DEV}/WEB-INF/classes"
def DIR_TEST_CLASSES
= "build/classes/test"
def DIR_TEST_RESOURCES
= "build/resources/test"
eclipse {
project {
referencedProjects "${CSOS}"
}
classpath {
// Remove the comment below to get rid of Eclipse classpath file duplicates
//downloadSources = false
plusConfigurations += configurations.gwt // ensure gwt dependencies are included
defaultOutputDir = new File(DIR_CLASSES)
// separate the main and test eclipse output into separate folders
file {
whenMerged { cp ->
cp.entries.findAll { it instanceof SourceFolder && it.path.startsWith("src/main") }*.output = "${DIR_CLASSES}"
cp.entries.findAll { it instanceof SourceFolder && it.path.startsWith("src/test/java") }*.output = "${DIR_TEST_CLASSES}"
cp.entries.findAll { it instanceof SourceFolder && it.path.startsWith("src/test/resources") }*.output = "${DIR_TEST_RESOURCES}"
}
}
}
}
On the main project, “gradle dependencies” produces
runtime - Runtime classpath for source set 'main'.
...
+--- net.sf.gilead:gilead4gwt:1.3.0
|
+--- net.sf.gilead:gilead-core:1.3.0 (*)
|
+--- net.sf.gilead:gilead-hibernate:1.3.0
|
|
+--- net.sf.gilead:gilead-core:1.3.0 (*)
|
|
+--- org.hibernate:hibernate:3.2.6.ga
|
|
|
+--- net.sf.ehcache:ehcache:1.2.3
|
|
|
|
\--- commons-collections:commons-collections:2.1 -> 3.2
...
After “gradle eclipse”, eclipse complains about the .classpath file stating
Build path contains duplicate entry: '<repository-path>/filestore/commons-collections/commons-collections/3.2/jar/<md5>/commons-collections-3.2.jar for project <name>
And the .classpath file contains the following duplicate entries
<classpathentry sourcepath="C:/Users/pwills/.gradle/caches/artifacts-24/filestore/commons-collections/commons-collections/3.2/source/73d0340eaecbb0ec9d3e0ace90547ef08cbfaf27/commons-collections-3.2-sources.jar" kind="lib" path="C:/Users/pwills/.gradle/caches/artifacts-24/filestore/commons-collections/commons-collections/3.2/jar/f951934aa5ae5a88d7e6dfaa6d32307d834a88be/commons-collections-3.2.jar" exported="true"/>
<classpathentry kind="lib" path="C:/Users/pwills/.gradle/caches/artifacts-24/filestore/commons-collections/commons-collections/3.2/jar/f951934aa5ae5a88d7e6dfaa6d32307d834a88be/commons-collections-3.2.jar" exported="true"/>
If I change the eclipse task so that downloadSources = false, then the duplicate disappears.