includeFlat and "cyclic reference"

So - we have “uncommon” workspace that looks like this:

/ /project1/… project1 files … /project1/settings.gradle /project1/build.gradle /project2/… project2 files …

I want to be able to build project2, and project1 that depends on it. The problem is - the gradle doesn’t know which project is root one, and throws error at me when i try to load it inside IDEA or even build it. And I, even after using Google and searching forums, still don’t know if it’s possible to do that and if it is, how?

Here is settings.gradle:

includeFlat 'project1', 'project2'

I tried to set

and play with it. I even tried to manipulate with


. If scripts are moved to different directory (same level) everything start to work - but I need build script to be placed inside project1 because of “unusual” project requirements.

You need to remove ‘includeFlat ‘project1’’, because that’s the root project, and the root project is always included automatically. Also you’ll need to execute all builds from the ‘project1’ directory (or pass that directory via ‘-p’), so that Gradle finds ‘settings.gradle’. You can run a project2 task with ‘gradle :project2:someTask’. You cannot ‘cd’ into ‘project2’ and run ‘gradle someTask’, as you would normally do.