title: Gradle: Adding publish task of submodule as dependency to another submodule
body: <p>My project layout is like this</p>
  
  <pre><code>A
  ├── B
  │   ├── build.gradle
  │   └── Example-0.0.1.jar
  ├── build.gradle
  ├── C
  │   ├── build.gradle
  │   └── src
  │       └── main
  │           └── java
  │               └── com
  │                   └── sample
  │                       └── Hello.java
  └── settings.gradle
  </code></pre>
  
  <p>Now, B uses maven-publish to publish Example-0.0.1.jar to local maven archives (i.e ~/.m2/repositories)</p>
  
  <p>C is a java project. The Hello.java file uses the Example jar file.</p>
  
  <p>I am using gradle 2.2 to build this project.
  I have </p>
  
  <pre><code>$ cat A/build.gradle 
  allprojects {
          repositories {
                  mavenCentral()
                  mavenLocal()
          }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>$ cat A/settings.gradle 
  include ':B'
  include ':C'
  </code></pre>
  
  <p>and</p>
  
  <pre><code>$ cat A/B/build.gradle 
  apply plugin: 'maven-publish'
  
  publishing {
          publications {
                  maven(MavenPublication) {
                          groupId 'com.example'
                          artifactId 'abc'
                          version '0.0.1'
                          artifact 'Example-0.0.1.jar'
                  }
          }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>$ cat A/C/build.gradle 
  apply plugin: 'java'
  apply plugin: 'maven'
  
  dependencies {
          compile project(':B')
          compile 'com.example:abc:0.0.1'
  }
  </code></pre>
  
  <p>Now, whenever I run any gradle command, I get the following error:</p>
  
  <pre><code>$ gradle tasks
  Execution failed for task ':tasks'.
  &gt; Could not determine the dependencies of task ':C:compileJava'.
  </code></pre>
  
  <p>Is there any way such that task B:publishToMavenLocal be run before building of C in order to include the jar?</p>