Hi,
I’m having difficulties configuring a build so a transitive dependency is excluded in one configuration, but present in another one. I created a simple build.gradle
file that I can use to reproduce the problem.
For instance, if I declare a compile dependency on quartz
, which transitively depends on slf4j-api
, and explicitly exclude the slf4j-api
dependency in the compile configuration, declaring a testRuntime dependency on slf4j-api
doesn’t seem to work - looks like the testRuntime dependency is suppressed by the compile exclusion rule.
This is my build.gradle
file:
repositories {
jcenter()
}
apply plugin: 'java'
dependencies {
compile group: 'org.quartz-scheduler', name: 'quartz', version: '2.3.0'
configurations.compile.exclude(group: 'org.slf4j', module: 'slf4j-api')
testRuntime group: 'org.slf4j', name: 'slf4j-api', version: '1.7.7'
}
And the dependencies resolved by Gradle:
compile - Dependencies for source set 'main' (deprecated, use 'implementation ' instead).
\--- org.quartz-scheduler:quartz:2.3.0
+--- com.mchange:c3p0:0.9.5.2
| \--- com.mchange:mchange-commons-java:0.2.11
+--- com.mchange:mchange-commons-java:0.2.11
\--- com.zaxxer:HikariCP-java6:2.3.13
testRuntime - Runtime dependencies for source set 'test' (deprecated, use 'testRuntimeOnly ' instead).
\--- org.quartz-scheduler:quartz:2.3.0
+--- com.mchange:c3p0:0.9.5.2
| \--- com.mchange:mchange-commons-java:0.2.11
+--- com.mchange:mchange-commons-java:0.2.11
\--- com.zaxxer:HikariCP-java6:2.3.13
Is there any error with my configuration? Is Gradle resolving the dependencies as expected? How can I express the exclusion of a dependency in one configuration only, but not in others?
Thank you,
Douglas