Imagine you have simple multi-project build with one root project and one subproject:
root
|--sub
| `----build.gradle
|----build.gradle
`----settings.gradle
settings.gradle:
include ':sub'
root/build.gradle:
apply plugin: 'java'
sub/build.gradle:
sourceSets {
println "sourceSets:" + main.java.srcDirs
}
then the sourceSet
setting leaks from the rootProject into the sub
project even though it does not specify the java or java-base plugins.
I've run into an issue with one custom plugin that is reading the project's sourceSets. When it is applied on the sub project that does not have the java plugin applied it basically reads sourceSet of the rootProject where in fact it should have failed with an error because of missing sourceSet due to not having the java plugin applied. I know that this is happening mainly because of poorly written custom plugin, but I think this might cause some unwanted surprises in some cases.
Is this "leakage behavior" of the java plugin intentional?
I know this is poorly written question, but SO is the place no.1 to visit when solving issues with gradle.