Is it possible to have a child project that comes from a directory above the main project?


(Maxwell Stein) #1

Module A is the main module and is needed by ProjectB and ProjectC. The directory structure is

/Module/ModuleA /Projects/ProjectB /Projects/ProjectC

So I would live to be able to have projectB (or C) depend on ModuleA. Is this possible?


(Peter Niederwieser) #2

Yes it’s possible. See the multi-project builds chapter in the Gradle user guide, in particular the custom layout section.

One thing to keep in mind is that if ‘settings.gradle’ is not in a common parent directory, you lose the ability to cd into a subproject directory and run the build from there. (You can still run a single task by using the task’s fully qualified pathname though.)


(Maxwell Stein) #3

Thank you for your response. I have read through those chapers, but I’m not having any luck changing ModuleA’s buildpath

settings.gradle (in ProjectB)

rootProject.name = 'Project B'
project(':projectA').projectDir = new File(settingsDir, '../modules/ModuleA')
include projectA

I’m seeing this error however: Project with path ‘:projectA’ could not be found. I’m sure I’m missing something fairly obvious, but I can’t seem to narrow it down.

Thanks again for your time.


(Peter Niederwieser) #4

The ‘include’ has to come first as it “declares” the project.


(Maxwell Stein) #5

ha. of course.

Thanks.