Dependencies in Multi Project Build

I have a little multi project setup where it says in settings.gradle at the top level:

include ‘c’, ‘a’, ‘b’

reflecting the order in which the sub projects should be built to reflect their mutual dependencies. Still it seem that they are compiled in alphabetical order ‘a’, ‘b’, ‘c’. What am I doing wrong?

Hi Martin, the order of your projects in the include statement is not reflected during the build. the default for handling projects is the alphabetical order as you noticed. Declaring mutual deps of your sub projects, you have to use the dependency block in the sub projects build script. If project a depends on project c, you have to declare this dependency in cs’ build script by adding:

dependencies{
   compile project('a')
}

regards, René

an alternative (and perhaps more natural?) way of defining project dependencies is the ‘dependsOn’ syntax.

Example:

//a/build.gradle
  dependsOn(":b")

or equivalently using the root build file:

//root build.gradle
  project(":a").dependsOn(":b")

where the colon syntax in expressions like “:b” is an “absolute project path” to the “b” project. This is similar to the *nix file system syntax slash usage in paths like “/var/log/”.