title: Gradle - Multi projects - flat directory structure all at same level
body: <p>Gradle multi individual dependent Java projects. With flat folder structure all at same levels.</p>
  
  <p>I am trying to create multi gradle Java projects like this.</p>
  
  <ul>
  <li>Child1 - Depends on nothing (Data layer)</li>
  <li>Child2 - Depends only on Child1  (Business layer)</li>
  <li>Parent - Depends only on Child2  (Service Layer)</li>
  </ul>
  
  <p>I am able to make it work only with the below configurations. I am not sure if this is the right approach to achieve the above requirements.</p>
  
  <p><strong>Child2 - settings.gradle</strong></p>
  
  <pre><code>include ':Child1'
  project(':Child1').projectDir = new File(settingsDir, "../Child1"); 
  </code></pre>
  
  <p><strong>Child2 - build.gradle</strong></p>
  
  <pre><code>dependencies {
      compile project(':Child1')
  }
  </code></pre>
  
  <p><strong>Parent - settings.gradle</strong></p>
  
  <pre><code>include ':Child1', ':Child2'
  project(':Child1').projectDir = new File(settingsDir, "../Child1");
  project(':Child2').projectDir = new File(settingsDir, "../Child2");
  </code></pre>
  
  <p>Note:- I wonder why should we define Child1 details here ?? Because Parent just needs the Child2 dependency. If I don't configure like above it does not works.</p>
  
  <p><strong>Parent - build.gradle</strong></p>
  
  <pre><code>dependencies {
      compile project(':Child2')
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/BtyJ9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BtyJ9.png" alt="enter image description here"></a></p>