Apparently dependency exclusions can’t be injected in a multi-project build with a ‘allprojects’ or ‘subprojects’ block. They do work when they are defined directly in the subproject build files. Here are the script files:
‘settings.gradle’:
include "common-server"
‘build.gradle’:
apply plugin: "base"
allprojects {
buildDir = "output"
version = "4.2.0.999"
repositories {
mavenCentral()
}
configurations {
all*.exclude group: 'log4j', module: 'log4j'
}
}
‘common-server/build.gradle’:
apply plugin: "java"
dependencies {
compile group:"org.slf4j", name:"slf4j-log4j12", version:"1.6.4"
}
‘gradle :common-server:dependencies’ output:
compile - Classpath for compiling the main sources.
\--- org.slf4j:slf4j-log4j12:1.6.4 [default]
+--- org.slf4j:slf4j-api:1.6.4 [compile,master,runtime]
\--- log4j:log4j:1.2.16 [compile,master,runtime]
When I remove the configurations block from the root build.gradle, and add it to common-server/build.gradle, it works.
‘common-server/build.gradle’:
apply plugin: "java"
configurations {
all*.exclude group: 'log4j', module: 'log4j'
}
dependencies {
compile group:"org.slf4j", name:"slf4j-log4j12", version:"1.6.4"
}
‘gradle :common-server:dependencies’ output:
compile - Classpath for compiling the main sources.
\--- org.slf4j:slf4j-log4j12:1.6.4 [default]
+--- org.slf4j:slf4j-api:1.6.4 [compile,master,runtime]