0

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.

Fanick
  • 610
  • 7
  • 23
  • Are you sure that `apply plugin: 'java'` is not inside a `allprojects { ... }` or `subprojects { ... }` closure in the root project? – lance-java Mar 07 '17 at 13:23
  • @Lance Java Yes, I'm sure the plugin is applied only on the root project. – Fanick Mar 08 '17 at 06:18

0 Answers0