title: Gradle Multi-Module Project Setup
body: <p>I've recently started using Gradle and replacing my existing Maven-based projects. I have had many issues in the past with handling multi-module builds with Maven. Gradle has been a breath of fresh air when handling multi-module buils, but it's not perfect yet.</p>
  <p>I have the following folder layout for my projects:</p>
  <pre><code>-- Projects
  ---- EnterpriseApp1
  ------ EarProject
  -------- build.gradle
  ------ EjbProject
  -------- build.gradle
  ------ WarProject
  -------- build.gradle
  ------ properties.gradle
  ------ build.gradle
  ---- CommonLib
  ------ build.gradle
  ---- ClientApplication
  ------ build.gradle
  </code></pre>
  <p>The problem I am having is that the &quot;EnterpriseApp1&quot; and &quot;ClientApplication&quot; both depend on the CommonLib project. I don't know how to configure my &quot;EnterpriseApp1&quot; build file to use the CommonLib project as dependency for the &quot;EjbProject&quot;. I have come very close to getting this to work, but not quite working yet. I have had success by copying the CommonLib folder inside &quot;EnterpriseApp1&quot;, but that's not a long term solution.</p>
  <p>Here's my current properties.gradle file in &quot;EnterpriseApp1&quot;:</p>
  <pre><code>include &quot;EarProject&quot;, &quot;EjbProject&quot;, &quot;WarProject&quot;
  includeFlat &quot;CommonLib&quot;
  </code></pre>
  <p>According to the Gradle documentation the &quot;includeFlat&quot; command in the &quot;settings.gradle&quot; file will include projects on the same level as the folder where the &quot;settings.gradle&quot; file resides (desired behavior).</p>
  <p>EnterpriseApp1/build.gradle file:</p>
  <pre><code>subprojects {
     apply plugin: 'java'
  
     sourceCompatibility  = 1.6
     group = 'org.example'
     version = '1.0-SNAPSHOT'
  
     repositories {
        mavenCentral()
        ...
     }
  
     dependencies {
  
     }    
  }
  </code></pre>
  <p>EnterpriseApp1/EjbProject/build.gradle:</p>
  <pre><code>apply plugin: 'java'
  
  sourceCompatibility  = 1.6
  
  repositories {
     mavenCentral()
     ...
  }
  
  dependencies {
     compile project(':CommonLib')
  
     compile group: 'org.restlet.jee', name: 'org.restlet', version: '2.0.11'
     compile group: 'ma.glasnost.orika', name: 'orika-core', version: '1.0'
     ...
     compile group: 'javax.jmdns', name: 'jmdns', version: '3.4.1'
  }
  </code></pre>
  <p>When I execute &quot;gradle clean build&quot; from the EnterpriseApp1 folder all the dependencies are downloaded as expected and the projects begin to compile (including the CommonLib project), but the EjbProject project fails during the build due to the fact it's missing the CommonLib jar reference. Gradle is not smart enough (or I'm completely clueless ;)) to configure my EjbProject to use the Jar generated from the CommonLib project build stage.</p>
  <p>I apologize for the long and complicated setup. I have been working on trying to figure this out for some time now, but have nearly ran out of ideas. I would really appreciate any help for the community.</p>
  <p>Thanks!</p>