Gradle Include Dependency on another Project and Execution Order

By Arvind Rai, September 20, 2014

In this page we will learn how to refer gradle dependency of another project. We will also see that if there are more than one project, then how will be their execution order. Gradle provide keywords like include and project, which helps to achieve the dependency of another project. To understand these concept, we have taken three project in our example. These are ProjectOne, ProjectTwo and MainProeject. ProjectOne and ProjectTwo are being used in MainProject. Find the project structure in eclipse.

Use project keyword to define the location. Here settingsDir is the combination of two word settings + Dir. The file name will be with first word that is settings.gradle. Now find the MainProject build.gradle.
build.gradle in MainProject

Gradle Execution Order

Gradle Execution Order is acyclic. Gradle guarantees the execution order according to their dependency. We need not to worry about the order. If there are two project and if they are not mutually dependent then the execution order will be alphabetical. In our Example when we run gradle clean build on MainProject, then the execution order will be ProjectOne then projectTwo. These projects are not mutually dependent , so their execution order will be alphabetical. Check the build Log.