Dependent projects clarification

I am extremely new to Gradle, so please forgive my ignorance if my question sounds stupid.

I have 3 projects which I am converting to Gradle viz. Client, Server and Util.

Project Client uses project Server.

Project Server uses project Util.

My folder structures are as follows:

Java
|
|–Apps
| |–MyApp
| |–Client
| |–Server
|–Util

The Util build.gradle works as expected.

The Server settings.gradle file is as follows:

include ‘:Util’
project(‘:Util’).projectDir = new File(settingsDir, ‘…/…/…/Util’)

The Server build.gradle has the following and works as expected:

dependencies {
compile project(‘:Util’)
}

The confusion I have is with the Client. Client depends on Server, and Server depends on Util. In my client, it won’t build unless I do the following:

include ‘:Server’
project(‘:Server’).projectDir = new File(settingsDir, ‘…/Server’)
include ‘:Util’
project(‘:Util’).projectDir = new File(settingsDir, ‘…/…/…/Util’)

Why do I need to include Util in the settings.build file for Client even though it’s only a dependency for Server? If I exclude it from my client settings.gradle file, I get the following error when trying to build client:

Project with path ‘:Util’ could not be found in project ‘:Server’.

I would prefer not to have to specified all the paths in settings.build for projects I am not directly dependent on, and have it leverage the settings.build file for the directly dependent project instead.

Any pointers on how I can resolve this would be much appreciated!

Thanks.

There should only be one settings.gradle in you root project, which should include all other projects. Please refer to the user guide on multi-project builds.