Gradle is a project build automation tool that uses a Groovy DSL. Gradle build scripts support Maven and Ivy repositories as well as plain file system for dependency management.
Gradle is a build automation tool focused on flexibility and performance. Gradle build scripts are written using a groovy or kotlin DSL. Gradle allows the use of maven, ivy, or user-defined repositories for dependency management.
Why Gradle?
- Polyglot Builds: build in 60 different programming languages
- Tool Integration: like eclipse, android-studio, intellij, etc.
- Robust Dependency Management
- Powerful Yet Concise Logic: declarative and imperative
- High Performance Builds
- Build Reporting
Gradle allows you to describe the automation of a project build both declaratively and imperatively as you have the full power of the groovy programming language to describe Gradle tasks.
There are many plugins for Gradle. Both native ones like the "War" plugin and third-party ones. These can be found at plugins.gradle.org
Latest Version: 7.6 (Nov 25, 2022)
The default name for the build script is build.gradle
Expressing a project dependency
repositories {
mavenCentral()
}
dependencies {
testCompile 'junit:junit:4.12'
}
Defining a task
Using a groovy closure in defining a task count action:
task count {
doFirst {
4.times { print "$it " }
}
}
Output of running gradle -q count
:
> gradle -q count
0 1 2 3
Links:
Related tags:
- android-gradle
- build.gradle
- gradle-eclipse
- gradle-plugin
- gradle-2
- gradle-custom-plugin
- gradle-tomcat-plugin
- gradle-project
- gradle-kotlin-dsl
Tips:
- An easy way to update and manage your Gradle distributions is with SdkMan which works on UNIX based platforms or the powershellport POSH-GVM on windows.