Gradle Local Project Dependencies

Here’s a sample structure of the project we want to work with. Having a project dependent on another project or library is a common scenario. Let’s assume you have an application AProject which depends upon core-lib for some packages and you want to have local project dependencies. You can setup local project dependency in gradle as follows:

AProject/
  build.gradle
  src/main/java/com.package/

core-lib/
  build.gradle
  settings.gradle

In the settings.gradle file for core-lib, add a includeFlat directive

includeFlat 'AProject'

In the build.gradle for the AProject, specify this as needed during compile in the dependencies section (or set as needed during test etc if needs be).

dependencies {
       compile project(':AProject')
}

Now when you build you will pull in the dependent project. Project AProject needs to be a Gradle project. Also to get everthing work out fine, few assumptions on this scenario are both the project are on the same level in a directory structure and both parent and child project are gradle projects.