I'm trying to write a gradle build with 3 modules (A,B,C). A depends on B and B depends on C (A->B->C). All modules lie in the same parent directory.
All off the modules can either be present in the workspace or not, this is why my settingsB.gradle looks like this:
if(new File("../C").exists()){
include 'C'
project(":C").projectDir = file("../C")
}
within the dependencies I do the same check:
dependencies {
if(new File("../C").exists()) {
compile project(':C')
}else {
compile "com.mycompany.C:0.0.14"
}
This setup works perfectly, but not with the toplevel module A. If I add B to A, in the same way like above, I get an error while building project A:
Build file 'C:\projects\A\build.gradle' line: 44 A problem occurred evaluating project ':B'. Project with path ':C' could not be found in project ':B'.
The only way to solve this is to add module C to the settings.gradle of project A.
Is there any other way to solve the error ?
Thank you in advance
The solution is a compostie build (https://docs.gradle.org/current/userguide/composite_builds.html)
settingsA.gradle
settingsB.gradle