Auto-discovery of multi-project build instead of settings.gradle

Is it currently possible to “auto-discover” sibling projects in a multi-project build situation rather than specify them with setting.gradle? We have nearly 20 smallish projects that at different times will have project vs. jar dependencies depending on what a given coding effort calls for.

What I would like to have happen is that the run of a gradle build against a given project will navigate up one directory and search for sibling gradle projects. If a given sibling project is found, it becomes part of the multi-project build, if not found, the jar dependency would be used.

We currently manage the jar vs project with code in each sub-projects build.gradle that look like this:

if (isProjectCheckedOut(“module-dto”) )

{

compile project(’:module-dto’)

}

else

{

compile group: rootProject.group, name: ‘module-dto’, version:rootProject.version

}

where isProjectCheckedOut looks for the specified sibling project with some validation.

If this is not currently available “out of the box”, would the gradle plugin architecture allow for control of multi-project builds such that this is possible?

There is no out of the box functionality for this available in gradle. But it shouldn’t be that complicated to implement such functionality on your own.

  1. in your settings.gradle file you can implement a dynamic way to include your subprojects. this dynamic resolving of sub projects might base on existing folders or something more sophisticated.

  2. in the dependency section of your several sub projects you can use the allprojects property of project to implement your isProjectCheckedOut method above. If you need more detailed pointers on how to implement this, don’t hesitate to ask.

regards, René