title: Gradle dependency between subprojects
body: <p>I am trying to figure out the proper way to declare a project dependency in gradle, i have this two subprojects:</p>
  
  <p>A java app</p>
  
  <pre><code>apply plugin: 'java'
  
  sourceSets {main {java {srcDirs = ['./']}}}
  dependencies{compile project(':p2')}
  
  jar {manifest.attributes(
          'Class-Path': configurations.runtime.files.collect { it.name }.join(''),
          'Main-Class': 'Main'
      )
  }
  </code></pre>
  
  <p>and a java library:</p>
  
  <pre><code>apply plugin: 'java-library'
  
  sourceSets {main {java {srcDirs = ['./']}}
  }
  
  jar {
     manifest.attributes(
      'Class-Path': configurations.runtime.files.collect { it.name }.join(' ')
  )
  }
  </code></pre>
  
  <p>The root project is empty and the settings just include the subprojects.</p>
  
  <p>The <code>dependencies</code> in the p1 project only tells that p2 must be built before p1, but what about configuring p2 as a lib for p1? Right now if a run p1 i got:
  <code>Exception in thread "main" java.lang.NoClassDefFoundError: StaticClass</code></p>
  
  <p>Gradle build is fine:</p>
  
  <pre><code>C:\...&gt;gradle build
  BUILD SUCCESSFUL in 1s
  4 actionable tasks: 4 up-to-date
  </code></pre>
  
  <p>I have to copy and paste p2.jar to the p1.jar directory for it to run properly, how can i get gradle to do it for me?</p>