It seems this behavior is caused by specifying the sourceCompatibility
before apply plugin: 'java'
, which happens if you try to set the compatibility option inside allprojects
.
In my setup, the situation can be solved by replacing:
allprojects {
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
with:
allprojects {
apply plugin: 'java'
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
Will be glad if anyone else can verify this in a different setup.
I am still not sure whether this should be reported as a bug but I believe this solution is better than the work-around mentioned above (which has been very helpful however).