I am expriencing a strange behavior in gradle dependency management, where project A references project B as compile dependency and project B references library C as runtime dependency. Now I can use classes from library C in my project A.
My question: (Why) is this a bug or a feature?
The problem can be reproduced with gradle 2.9 and 2.10 and the following minimal setup:
// settings.gradle
include ':A', ':B'
// build.gradle
allprojects {
apply plugin: 'java'
apply plugin: 'maven'
repositories {
mavenLocal()
mavenCentral()
}
}
project(':A') {
dependencies {
compile project(':B')
}
}
project(':B') {
dependencies {
runtime "org.slf4j:slf4j-log4j12:1.7.13"
}
}
As you can see, a gradle :A:dependencies
shows
[...]
compile - Compile classpath for source set 'main'.
\--- project :B
\--- org.slf4j:slf4j-log4j12:1.7.13
+--- org.slf4j:slf4j-api:1.7.13
\--- log4j:log4j:1.2.17
[...]
and using log4j is totally possible in java code residing in project A.