# What is Gradle? * Build automation tool. * Takes your code and packages it into deployable unit. * Can be used on small and large projects. * It is written in the Kotlin language. * Gradle build scripts can be built using Kotlin or Groovy. * It is highly configurable to meet project needs. # Why use Gradle ? * Gradle makes building & running application very easy. * No need for people using your project to install Gradle. A Gradle wrapper is bundled with every project. Just run `./gradlew build`. * It is very concise and less verbose like tools like Maven because the build is defined in code rather than XML. * It is very fast and supports incremental builds so unchanged code is not rerun unnecessarily. For example, it wont run the same tests if the code does not change # What are the Key Gradle Concepts? 1. build.gradle.kts 1. This is the Gradle build script file and it is written in a Kotlin DSL (Domain Specific Language). 2. It is equivalent to Maven's pom.xml. 3. It lives in the top level of the project. ![[build-gradle-kts-file.png]] 3. Tasks 1. A task defines a unit of work to be executed. Tasks are invoked from the command line. 2. See available tasks by running `./gradlew tasks`. 3. Custom tasks can be created if the needed functionality does not already exists. 4. Tasks can have dependencies on other tasks. Therefore, the tasks depended on run first. 5. All the dependencies between tasks in a project create a task graph. 4. Wrapper 1. The Gradle wrapper script is used to invoke Gradle and run tasks. 2. The wrapper script is always committed into a project's version control. Therefore, no local Gradle installation is required for anyone building the project. 3. The Gradle wrapper contains a specific version of Gradle for every project. Therefore, always use the Gradle wrapper to build projects to avoid compatibility issues. 4. The Gradle wrapper is not used when initializing a new Gradle project. Initializing a Gradle project will require a local Gradle installation.