Confused about subproject refs in generated settings.gradle

I’ve assembled a handful of smal multiproject Gradle builds. The “settings.gradle” for them look pretty straightforward. For instance, here’s one simple one:	= 'uslMonitor'
include 'uslMonitorService', 'uslMonitorGUI'

In the “uslMonitor” directory, there are two subdirectories with those names.

Today I tried using “gradle init” in a large Maven multimodule build to see what obstacles I would have in a Gradle implementation. The project structure has a root project that contains an aggregator pom, listing all of the modules to be built. One of those modules is just a pom file, which is referenced as the parent pom for all the other module pom.xml files.

The resulting “settings.gradle” file looks like this: = 'usl-parent'
include ':usl-parent-pom:usl-base'
include ':usl-parent-pom:usl-device-api'
include ':usl-parent-pom:usl-device-impl'
project(':usl-parent-pom:usl-base').projectDir = "$rootDir/usl-base" as File
project(':usl-parent-pom:usl-device-api').projectDir = "$rootDir/usl-device-api" as File
project(':usl-parent-pom:usl-device-impl').projectDir = "$rootDir/usl-device-impl" as File

The root directory is named “usl-parent”. The subdirectory of that which has the parent pom is “usl-parent-pom”. I don’t know why it included “:usl-parent-pom:” as a prefix for all of the projects, as if usl-parent-pom is a subproject that contains those other subprojects.

I tried replacing “:usl-parent-pom:” with an empty string in the whole file, but that fails with:

A problem occurred evaluating settings 'usl-parent'.
Project with path 'usl-base' could not be found.

I’m confused.

I then also removed “:usl-parent-pom:” from all the project references in all the subprojects.

Now, when I try to run “gradle build” from the root (usl-parent), I get:

Build file 'C:\Users\dk068x\git\oce_usl\usl-parent\usl-account-api\build.gradle' line: 4

* What went wrong:
A problem occurred evaluating project ':usl-account-api'.
> Project with path 'usl-base' could not be found in project ':usl-account-api'.

In “usl-account-api/build.gradle”, I see this:

description = 'usl-account-api'
dependencies {
   compile project('usl-base')

Back in usl-parent/settings.gradle, we have this: = 'usl-parent'
include 'usl-base'

As you can see, I have a very simple structure, one directory with one level of subdirectories, each corresponding to a project. I don’t understand what I have wrong.

This is relative to the current project (so it’s looking for a project with the absolute path :usl-account-api:usl-base). I think you want an absolute reference. (:usl-base).

The direct analog to the parent pom structure is to convert the Maven parent pom relationship into a project/subproject relationship. That means the parent pom is a project and have all of the other projects are subprojects to it. That’s why you had the funky project paths (:usl-parent-pom:usl-base) that required additional configuration to specify a non-default project directory.

Thanks. That was it. Is it reasonable to consider that Gradle could emit a more intelligent error message, proposing the possibility that perhaps “foo” should be “:foo” or some variant?