Stack Exchange
Gradle dependencies not found in mutil project setup?
I have a project setup like this
+ rootProject
    + module1
       + src
         build.gradle
    + module2
       + src
         build.gradle
    + src
      build.gradle
      settings.gradle

Content of rootProject/build.gradle
evaluationDependsOn(':module1')

apply plugin: 'java'

dependencies {
  compile project(':module1')
  compile project(':module2')
}


task myTask (type: JavaExec) {
    main = 'org.gradle.example.Test.Main'
    classpath runtimeClasspath
  }

Content of module1/build.gradle
apply plugin: 'java'

repositories { 
  mavenCentral() 
}

dependencies { 
  compile 'commons-codec:commons-codec:1.9' 
}

Content of module2/build.gradle
apply plugin: 'java'

The dependencies graph
root --> module1 --> commons-codec
     --> module2

gradle report this at build with command gradle build in root folder
Could not resolve all dependencies for configuration ':compile'.
> Could not find commons-codec:commons-codec:1.9. Required by:
      :rootProject:unspecified > rootProject:codec:unspecified

if I add dependencies block in the rootProject's build file the it get build normally.
As you see, i already determine the dependencies in module1 build file. Why gradle keep saying that it couldnt resolve? 
Do i need to put all dependencies of submodule in root build files?

First of all I see that You're missing settings.gradle file which is necessary in multimodule projects. You need to create it at the same level as rootProject/build.gradle is located. 
The content should be
include 'module1', 'module2'

UPDATE
Ok, to root build.gradle added following piece of code:
allprojects {
    repositories {
        mavenCentral()
    }
}

And removed from module1/build.gradle the repositories section. Now it works. Dependencies are fetched and displayed. Currently no idea what is the explanation.

i had it, and its content is exactly what you suggest.

Well, ok. When I run gradle build it works perfectly fine. But there's no need for submodule dependencies to be put in rootProject's build file.

what version of gradle do you have?

can you make a try with this project https://github.com/gradleware/oreilly-gradle-book-examples/tree/master/multiproject-individual my project is built with same setting as this one

Hmm.. 1.11 But when I run gradle dependencies I see FAILED for commons-codec. Also added guava, result is the same. Will have a look in a moment.
