I have two local gradle projects, ProjectA and ProjectB. ProjectA is a multi module project which has modules Module1 and Module2. Module2 depends on Module1.
root/
ProjectA/
Module1/build.gradle
Module2/build.gradle
settings.gradle
build.gradle
ProjectB/
settings.gradle
build.gradle
I want to make ProjectB depend on Module2. I attempted to do this with the follow changes to ProjectB/settings.gradle:
include 'Module2'
project(':Module2').projectDir = file('../ProjectA/Module2')
and to ProjectB/build.gradle:
dependencies {
compile project(":Module2")
}
This results in the following error on build:
FAILURE: Build failed with an exception.
* Where:
Build file 'root\ProjectA\Module2\build.gradle' line: 2
* What went wrong:
A problem occurred evaluating project ':Module2'.
> Project with path ':Module1' could not be found in project ':Module2'.
I attempted to also include and depend on Module1 in ProjectB, however this resulted in properties from ProjectA/build.gradle allProjects not being resolved. I assume this is related to the root of the problem, but I am unsure of how to continue debugging.
Can I achieve this behavior?