Make a multi-project build behave like a Maven multi-module project

I have three Gradle builds: common, core and web. core and web both depend on common but web does not depend on core. core is a multi-project build. Here’s the file structure:

root
  common
    build.gradle
  core
    a/b/c
      build.gradle
    d/e/f
      build.gradle
    g/h/i
      build.gradle
    build.gradle
    shared.gradle
    settings.gradle
  web
    build.gradle

common can build by itself. web is set up so that it depends on common. When I run gradle build on core, it builds everything specified in the settings.gradle file correctly.

What my team would like to do is enable building from the root folder as well as the core folder. Currently they only have to type gradle in any of the top-level projects to build them and we’d like to keep it that way.

The problem comes in when I put a settings.gradle file in the root directory. Since the projects are now nested one level deeper, I need to include core/a/b/c instead of a/b/c. Some of the projects within core reference other projects and these references result in an error when building from the root directory (because core/a/b/c is a known project but a/b/c is not).

I tried fixing all of the references, but this prevents me from going to the core directory and building only the projects contained in core.

With Maven, this feature (building part of a project instead of the whole thing by changing to a subdirectory) seems to work in a very intuitive fashion. How can I set my Gradle project up to do the same thing?

What I want is to be able to run something like gradle clean build and have it run those tasks on each of the projects, but to run those tasks only on the projects contained within my current directory.

Sounds like you are using the wrong syntax for referencing projects. To make an absolute reference, the project path needs to start with a colon. E.g. :core:a:b:c. Also project paths should be separated by colons, not slashes. Otherwise you’ll get confusing half-working behavior. We will forbid slashes in names in future versions to make this clearer.

This was the exact problem. I had been putting :core/a/b/c instead of :core:a:b:c. Fortunately I had written a generator to create the build files so fixing this everywhere was quite easy to do.

Thank you for your help!