I have 3 separate Gradle projects - **x** depends on **y** depending on **z**.

**x/settings.gradle**

```
include ':y'
project(':y').projectDir = new File('../y')

```

**x/build.gradle**

```
apply plugin: 'java'

```

**y/settings.gradle**

```
include ':z'
project(':z').projectDir = new File('../z')

```

**y/build.gradle**

```
apply plugin: 'java'
dependencies {
    compile project(':z')
}

```

When I run `gradlew build` in **x** directory, I get error

```
* Where:
Build file 'C:\Temp\idea\y\build.gradle' line: 4

* What went wrong:
A problem occurred evaluating project ':y'.
  Project with path ':z' could not be found in project ':y'.

```

But running `gradlew build` in **y** directory is successful.

How should I configure **x** and **y** to avoid **y**'s dependencies affect **x**?