Gradle - Build


A build is a lifecyle task that executes a graph of task


Gradle executes build scripts in three fixed phases:

  • Initialization: Sets up the environment for the build and determine which projects will take part in it.
  • Configuration: Constructs and configures the task graph for the build and then determines which tasks need to run and in which order, based on the task the user wants to run.
  • Execution: Runs the tasks selected at the end of the configuration phase.

These phases form Gradle’s Build Lifecycle.



gradle build


Tasks should define inputs and outputs to get the performance benefits of an incremental build.

Gradle comes with a sophisticated incremental Java compiler that is active by default (ie cache is on) doc

Set Build File

Specify the build file.

gradle [-b|--build-file]

Set Property

Set project property for the build script (e.g. -Pmyprop=myvalue).

gradle -P, --project-prop       

Disable Cache

  • Disables the Gradle build cache.
gradle --no-build-cache          
  • Disable Task cache
gradlew build --rerun-tasks         


Dry run

Run the builds with all task actions disabled.

gradle [-m|--dry-run]


Powered by ComboStrap