I have a Gradle Project in Eclipse consisting of multiple subprojects. I currently have subprojects A, B and C.
Project A should have access to Project B. Project B should have access to Project C. But project A should not have access to Project C.
A -> B, B -> C, but not A -> C
I can easily test this by having a java example class in Project A which tries to use a class from Project C.
I've achieved this with Gradle using the following setup in the main build.gradle
file and using the transitive
property:
project(':projectA') {
dependencies {
compile project(':projectB'), {
transitive = false
}
}
}
project(':projectB') {
dependencies {
compile project(':projectC'), {
transitive = false
}
}
}
Running Gradle's compileJava
on Project A's example class gives the correct error message. I would like to have this error should up as a compile error in Eclipse. I was also able to manually configure the classpath in a way that the desired relationship holds, but a Gradle Refresh/Rebuild resets the classpath again.
Is it possible to use Gradle's Java Compiler instead of the Eclipse Compiler? Or should I influence the classpath files when doing a Gradle Refresh/Rebuild? Is there maybe a different solution?
I'd like to hear what is the preferred approach for this situation. Thanks!