From 529e1eb058a5679b3b4a8521260871d27a6716df Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 10 Feb 2016 12:39:18 +0100 Subject: [PATCH] Fix 'test' dependencies The previously used approach of project(':smack-core').sourceSets.test.runtimeClasspath caused the 'eclipse' target to produce duplicate classpath entries in .classpath when run with Gradle >= 2.6. It also relied on Gradle internals. Instead we now use project(path: ":smack-core", configuration: "testRuntime") project(path: ":smack-core", configuration: "archives") to be able to use test classes from other subprojects (usually smack-core) in e.g. smack-extensions. The 'archives' configuration includes the test jar. See also https://discuss.gradle.org/t/11784 Thanks to Lari Hotari for helping with this issue. --- build.gradle | 6 +++++- smack-debug-slf4j/build.gradle | 2 +- smack-debug/build.gradle | 2 +- smack-experimental/build.gradle | 3 ++- smack-extensions/build.gradle | 3 ++- smack-im/build.gradle | 3 ++- smack-jingle-old/build.gradle | 2 +- smack-legacy/build.gradle | 2 +- smack-sasl-javax/build.gradle | 3 ++- smack-sasl-provided/build.gradle | 3 ++- smack-tcp/build.gradle | 2 +- 11 files changed, 20 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index f45715092..07d07fd42 100644 --- a/build.gradle +++ b/build.gradle @@ -274,7 +274,7 @@ subprojects { classifier = 'javadoc' from javadoc.destinationDir } - task testJar(type: Jar) { + task testJar(type: Jar, dependsOn: testClasses) { classifier = 'tests' from sourceSets.test.output } @@ -293,6 +293,10 @@ subprojects { } } + configurations { + archivesOutput.extendsFrom (testCompile) + } + artifacts { archives sourcesJar archives javadocJar diff --git a/smack-debug-slf4j/build.gradle b/smack-debug-slf4j/build.gradle index 43f430dbb..bf1477b6e 100644 --- a/smack-debug-slf4j/build.gradle +++ b/smack-debug-slf4j/build.gradle @@ -6,5 +6,5 @@ Connect your favourite slf4j backend of choice to get output inside of it""" dependencies { compile project(':smack-core') compile 'org.slf4j:slf4j-api:[1.7,1.8)' - testCompile project(':smack-core').sourceSets.test.runtimeClasspath + testCompile project(path: ":smack-core", configuration: "testRuntime") } diff --git a/smack-debug/build.gradle b/smack-debug/build.gradle index 86a2bb290..3cc23ac14 100644 --- a/smack-debug/build.gradle +++ b/smack-debug/build.gradle @@ -4,5 +4,5 @@ Inspect the exchanged XMPP stanzas.""" dependencies { compile project(':smack-core') - testCompile project(':smack-core').sourceSets.test.runtimeClasspath + testCompile project(path: ":smack-core", configuration: "testRuntime") } diff --git a/smack-experimental/build.gradle b/smack-experimental/build.gradle index 7108c646b..d6b8c2582 100644 --- a/smack-experimental/build.gradle +++ b/smack-experimental/build.gradle @@ -7,5 +7,6 @@ between patch versions.""" dependencies { compile project(':smack-core') compile project(':smack-extensions') - testCompile project(':smack-core').sourceSets.test.runtimeClasspath + testCompile project(path: ":smack-core", configuration: "testRuntime") + testCompile project(path: ":smack-core", configuration: "archives") } diff --git a/smack-extensions/build.gradle b/smack-extensions/build.gradle index ade5dccbf..2ae9f9c19 100644 --- a/smack-extensions/build.gradle +++ b/smack-extensions/build.gradle @@ -10,5 +10,6 @@ dependencies { // Some implementations need APIs provided by smack-im, // e.g. message delivery receipts the roster compile project(':smack-im') - testCompile project(':smack-core').sourceSets.test.runtimeClasspath + testCompile project(path: ":smack-core", configuration: "testRuntime") + testCompile project(path: ":smack-core", configuration: "archives") } diff --git a/smack-im/build.gradle b/smack-im/build.gradle index ca8b23e84..d1608591b 100644 --- a/smack-im/build.gradle +++ b/smack-im/build.gradle @@ -7,5 +7,6 @@ Roster, Chat and other functionality.""" // sourceSet.test of the core subproject dependencies { compile project(':smack-core') - testCompile project(':smack-core').sourceSets.test.runtimeClasspath + testCompile project(path: ":smack-core", configuration: "testRuntime") + testCompile project(path: ":smack-core", configuration: "archives") } diff --git a/smack-jingle-old/build.gradle b/smack-jingle-old/build.gradle index 3e27ba851..f73c62913 100644 --- a/smack-jingle-old/build.gradle +++ b/smack-jingle-old/build.gradle @@ -7,5 +7,5 @@ dependencies { compile project(':smack-extensions') compile 'javax.media:jmf:2.1.1e' compile files('libs/jspeex-0.9.7-jfcom.jar', 'libs/jstun.jar', 'libs/Speex.jar') - testCompile project(':smack-core').sourceSets.test.runtimeClasspath + testCompile project(path: ":smack-core", configuration: "testRuntime") } diff --git a/smack-legacy/build.gradle b/smack-legacy/build.gradle index 3faa82487..98c828ea4 100644 --- a/smack-legacy/build.gradle +++ b/smack-legacy/build.gradle @@ -6,5 +6,5 @@ Usually XEPs in the state 'retracted', 'rejected', 'deprecated', dependencies { compile project(':smack-core') compile project(':smack-extensions') - testCompile project(':smack-core').sourceSets.test.runtimeClasspath + testCompile project(path: ":smack-core", configuration: "testRuntime") } diff --git a/smack-sasl-javax/build.gradle b/smack-sasl-javax/build.gradle index 745fa57ec..af9d5af8c 100644 --- a/smack-sasl-javax/build.gradle +++ b/smack-sasl-javax/build.gradle @@ -4,5 +4,6 @@ Use javax.security.sasl for SASL.""" dependencies { compile project(path: ':smack-core') - testCompile project(':smack-core').sourceSets.test.runtimeClasspath + testCompile project(path: ":smack-core", configuration: "testRuntime") + testCompile project(path: ":smack-core", configuration: "archives") } diff --git a/smack-sasl-provided/build.gradle b/smack-sasl-provided/build.gradle index 402f9a2ae..4e284fd24 100644 --- a/smack-sasl-provided/build.gradle +++ b/smack-sasl-provided/build.gradle @@ -4,5 +4,6 @@ Use Smack provided code for SASL.""" dependencies { compile project(path: ':smack-core') - testCompile project(':smack-core').sourceSets.test.runtimeClasspath + testCompile project(path: ":smack-core", configuration: "testRuntime") + testCompile project(path: ":smack-core", configuration: "archives") } diff --git a/smack-tcp/build.gradle b/smack-tcp/build.gradle index 03eb40af3..1c174288a 100644 --- a/smack-tcp/build.gradle +++ b/smack-tcp/build.gradle @@ -3,5 +3,5 @@ Smack for standard XMPP connections over TCP.""" dependencies { compile project(':smack-core') - testCompile project(':smack-core').sourceSets.test.runtimeClasspath + testCompile project(path: ":smack-core", configuration: "testRuntime") }