SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
Introduction To Gradle
Topics
1. What is Build Tool?
2. Getting Started With Gradle
3. Building JVM Projects
What is Build Tool?
● Build tools are programs that automate the creation of executable
applications from source code.
● Building incorporates compiling, linking and packaging the code into a usable
or executable form.
What is Gradle?
Gradle is an open source build automation system that builds upon the concepts
of Apache Ant and Apache Maven and introduces a Groovy-based
domain-specific language (DSL) instead of the XML form used by Apache Maven
for declaring the project configuration.
Getting Started w/ Gradle
Installing Gradle
1. Download Gradle:
wget https://services.gradle.org/distributions/gradle-3.4.1-bin.zip
2. Install Gradle
sudo mkdir /opt/gradle
sudo unzip -d /opt/gradle gradle-3.4.1-bin.zip
export PATH=$PATH:/opt/gradle/gradle-3.4.1/bin
gradle -v
Starting a project
1. mkdir projectName
2. Initialize project structure
Create & edit build.gradle
Core Components
● Projects: A project is typically some software you want to build.
● Tasks: Tasks are actions needed to build the projectTasks are actions
needed to build the project
● Build scripts: The build script is typically called build.gradle and is
normally located in the root directory of the project
Gradle Tasks
● A task might be compiling some classes, creating a JAR, generating
Javadoc, or publishing some archives to a repository
● In simple words, a project is made up of different tasks.
Task Dependencies & Ordering
● dependsOn creates an execution dependency
● All execution dependencies of a task must also be executed and
completed before the task
Task Dependencies & Ordering
● finalizedBy creates a finalization dependency
● The finalizer task is added if the finalized task is present in the task graph
Adding Dependencies
● Dependencies are added to a Configuration
● JVM projects have
compile, runtime, testCompile, testRuntime
Locating Dependencies
● Gradle supplies some default repositories to search:
jcenter, mavenCentral, mavenLocal
● Can also look at custom maven,
ivy, and file system paths
Extra Properties
Extra properties extensions allow new properties to be added to existing domain
objects. They act like maps, allowing the storage of arbitrary key/value pairs.
Variables
Build scripts are Groovy, so you can also define variables normally
Plugins
● A plugin is a set of tasks
● A gradle plugin is library of code that, when loaded by Gradle build script,
adds new functionality and capabilities to the build system.
Plugins can −
● Extend the basic Gradle model (e.g. add new DSL elements that can be
configured).
● Configure the project according to conversions (e.g. add new tasks or
configure sensible defaults).
● Apply specific configuration
Types of Plugin
● Script Plugins
Script plugins can be applied from a script on the local filesystem or at a
remote location. Filesystem locations are relative to the project directory
apply from: 'other.gradle'
● Binary Plugins
Each plugin is identified by a plugin id. Some core plugins use short names to
apply it
apply plugin: JavaPlugin
Custom Plugin
apply plugin: CustPlugin
Class CustPlugin
implements Plugin<Project> {
void apply(Project project) {
project.task('hello'){
println "CUSTOM HELL-O"
}
}
}
Publishing Artifacts
● The files the project provides to the outside world. This might be a library
or a ZIP distribution or any other file. A project can publish as many
artifacts as it wants.
● The artifacts could be published to either local system or repository url
Gradle Wrapper
● When you use the Gradle Wrapper, you embed some intelligence into
your project. When some one runs the build for the first time, they run
“gradlew” which is an automatically generated shell script (or Batch script
on Windows) designed to download Gradle. As the build manager, you
generate this file from your Gradle build so that you don't have to write
instructions for installing Gradle.
● The Gradle Wrapper takes build automation to another level - Gradle can,
effectively, install itself.
Install Gradle Wrapper
● Install the Wrapper into your project by running the wrapper task. (This
task is always available, even if you don't add it to your build)
gradle wrapper --gradle-version 2.0
Or
task wrapper(type: Wrapper) {
gradleVersion = '2.0'
}
Thanks

More Related Content

PPSX
Typical layout of a Sub-Station
PDF
Introduction to DevOps
PPTX
An Introduction To REST API
PDF
Git and github 101
PDF
IoT module 3- 22ETC15H-2022-23 by Dr.Suresha V1.pdf
PDF
Ansible Introduction
PPTX
Docker Basics
PPTX
ISTQB-FL.pptx
Typical layout of a Sub-Station
Introduction to DevOps
An Introduction To REST API
Git and github 101
IoT module 3- 22ETC15H-2022-23 by Dr.Suresha V1.pdf
Ansible Introduction
Docker Basics
ISTQB-FL.pptx

What's hot (20)

PDF
Gradle Introduction
PPTX
PDF
An Introduction to Gradle for Java Developers
PPTX
Building with Gradle
PDF
Gradle - the Enterprise Automation Tool
PPTX
Maven ppt
PDF
Introduction to Git and GitHub
PDF
Spring Boot
PPTX
ASP.NET Core MVC + Web API with Overview
PPTX
Introduction git
PPT
Maven Introduction
PPTX
Spring boot
PPTX
Introduction to spring boot
PPTX
Introduction to Spring Boot
PDF
Angular Advanced Routing
PPTX
PPTX
Maven Basics - Explained
PPTX
Spring boot
PDF
Git & GitHub for Beginners
Gradle Introduction
An Introduction to Gradle for Java Developers
Building with Gradle
Gradle - the Enterprise Automation Tool
Maven ppt
Introduction to Git and GitHub
Spring Boot
ASP.NET Core MVC + Web API with Overview
Introduction git
Maven Introduction
Spring boot
Introduction to spring boot
Introduction to Spring Boot
Angular Advanced Routing
Maven Basics - Explained
Spring boot
Git & GitHub for Beginners
Ad

Viewers also liked (17)

PPTX
Introduction to es6
PPTX
PDF
Cosmos DB Service
PPTX
Actors model in gpars
PDF
Reactive java - Reactive Programming + RxJava
PDF
Unit test-using-spock in Grails
PDF
Java 8 features
PDF
Introduction to thymeleaf
PPTX
Progressive Web-App (PWA)
PDF
Spring Web Flow
PPTX
PPTX
Grails with swagger
Introduction to es6
Cosmos DB Service
Actors model in gpars
Reactive java - Reactive Programming + RxJava
Unit test-using-spock in Grails
Java 8 features
Introduction to thymeleaf
Progressive Web-App (PWA)
Spring Web Flow
Grails with swagger
Ad

Similar to Introduction to gradle (20)

PDF
Gradle
PPTX
Gradle,the new build system for android
PPTX
Faster java ee builds with gradle [con4921]
PDF
Gradle - Build System
PPTX
Faster Java EE Builds with Gradle
PDF
Gradle - Build system evolved
PPTX
Faster Java EE Builds with Gradle
PPTX
Build your android app with gradle
ODP
Eclipse Buildship JUG Hamburg
PDF
What's new in Gradle 4.0
PDF
ICONUK 2015 - Gradle Up!
PPTX
7 maven vsgradle
PPTX
Gradle : An introduction
PPTX
Android presentation - Gradle ++
PDF
Gradle explained
PDF
Pragmatic software development in kdb+
PDF
FOSDEM 2017: GitLab CI
PDF
Keeping your build tool updated in a multi repository world
PPTX
Gradle: One technology to build them all
PPTX
Gradle build capabilities
Gradle
Gradle,the new build system for android
Faster java ee builds with gradle [con4921]
Gradle - Build System
Faster Java EE Builds with Gradle
Gradle - Build system evolved
Faster Java EE Builds with Gradle
Build your android app with gradle
Eclipse Buildship JUG Hamburg
What's new in Gradle 4.0
ICONUK 2015 - Gradle Up!
7 maven vsgradle
Gradle : An introduction
Android presentation - Gradle ++
Gradle explained
Pragmatic software development in kdb+
FOSDEM 2017: GitLab CI
Keeping your build tool updated in a multi repository world
Gradle: One technology to build them all
Gradle build capabilities

More from NexThoughts Technologies (20)

PDF
PDF
Docker & kubernetes
PDF
Apache commons
PDF
Microservice Architecture using Spring Boot with React & Redux
PDF
Solid Principles
PDF
Introduction to TypeScript
PDF
Smart Contract samples
PDF
My Doc of geth
PDF
Geth important commands
PDF
Ethereum genesis
PPTX
Springboot Microservices
PDF
An Introduction to Redux
PPTX
Google authentication
Docker & kubernetes
Apache commons
Microservice Architecture using Spring Boot with React & Redux
Solid Principles
Introduction to TypeScript
Smart Contract samples
My Doc of geth
Geth important commands
Ethereum genesis
Springboot Microservices
An Introduction to Redux
Google authentication

Recently uploaded (20)

PPTX
1. Introduction to Computer Programming.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
August Patch Tuesday
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Empathic Computing: Creating Shared Understanding
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Getting Started with Data Integration: FME Form 101
PDF
Approach and Philosophy of On baking technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPT
Teaching material agriculture food technology
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Spectroscopy.pptx food analysis technology
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
1. Introduction to Computer Programming.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
August Patch Tuesday
Encapsulation_ Review paper, used for researhc scholars
Empathic Computing: Creating Shared Understanding
cloud_computing_Infrastucture_as_cloud_p
Getting Started with Data Integration: FME Form 101
Approach and Philosophy of On baking technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Group 1 Presentation -Planning and Decision Making .pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Teaching material agriculture food technology
Spectral efficient network and resource selection model in 5G networks
Network Security Unit 5.pdf for BCA BBA.
Spectroscopy.pptx food analysis technology
OMC Textile Division Presentation 2021.pptx
Accuracy of neural networks in brain wave diagnosis of schizophrenia

Introduction to gradle

  • 2. Topics 1. What is Build Tool? 2. Getting Started With Gradle 3. Building JVM Projects
  • 3. What is Build Tool? ● Build tools are programs that automate the creation of executable applications from source code. ● Building incorporates compiling, linking and packaging the code into a usable or executable form.
  • 4. What is Gradle? Gradle is an open source build automation system that builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy-based domain-specific language (DSL) instead of the XML form used by Apache Maven for declaring the project configuration.
  • 6. Installing Gradle 1. Download Gradle: wget https://services.gradle.org/distributions/gradle-3.4.1-bin.zip 2. Install Gradle sudo mkdir /opt/gradle sudo unzip -d /opt/gradle gradle-3.4.1-bin.zip export PATH=$PATH:/opt/gradle/gradle-3.4.1/bin gradle -v
  • 7. Starting a project 1. mkdir projectName 2. Initialize project structure Create & edit build.gradle
  • 8. Core Components ● Projects: A project is typically some software you want to build. ● Tasks: Tasks are actions needed to build the projectTasks are actions needed to build the project ● Build scripts: The build script is typically called build.gradle and is normally located in the root directory of the project
  • 9. Gradle Tasks ● A task might be compiling some classes, creating a JAR, generating Javadoc, or publishing some archives to a repository ● In simple words, a project is made up of different tasks.
  • 10. Task Dependencies & Ordering ● dependsOn creates an execution dependency ● All execution dependencies of a task must also be executed and completed before the task
  • 11. Task Dependencies & Ordering ● finalizedBy creates a finalization dependency ● The finalizer task is added if the finalized task is present in the task graph
  • 12. Adding Dependencies ● Dependencies are added to a Configuration ● JVM projects have compile, runtime, testCompile, testRuntime
  • 13. Locating Dependencies ● Gradle supplies some default repositories to search: jcenter, mavenCentral, mavenLocal ● Can also look at custom maven, ivy, and file system paths
  • 14. Extra Properties Extra properties extensions allow new properties to be added to existing domain objects. They act like maps, allowing the storage of arbitrary key/value pairs.
  • 15. Variables Build scripts are Groovy, so you can also define variables normally
  • 16. Plugins ● A plugin is a set of tasks ● A gradle plugin is library of code that, when loaded by Gradle build script, adds new functionality and capabilities to the build system. Plugins can − ● Extend the basic Gradle model (e.g. add new DSL elements that can be configured). ● Configure the project according to conversions (e.g. add new tasks or configure sensible defaults). ● Apply specific configuration
  • 17. Types of Plugin ● Script Plugins Script plugins can be applied from a script on the local filesystem or at a remote location. Filesystem locations are relative to the project directory apply from: 'other.gradle' ● Binary Plugins Each plugin is identified by a plugin id. Some core plugins use short names to apply it apply plugin: JavaPlugin
  • 18. Custom Plugin apply plugin: CustPlugin Class CustPlugin implements Plugin<Project> { void apply(Project project) { project.task('hello'){ println "CUSTOM HELL-O" } } }
  • 19. Publishing Artifacts ● The files the project provides to the outside world. This might be a library or a ZIP distribution or any other file. A project can publish as many artifacts as it wants. ● The artifacts could be published to either local system or repository url
  • 20. Gradle Wrapper ● When you use the Gradle Wrapper, you embed some intelligence into your project. When some one runs the build for the first time, they run “gradlew” which is an automatically generated shell script (or Batch script on Windows) designed to download Gradle. As the build manager, you generate this file from your Gradle build so that you don't have to write instructions for installing Gradle. ● The Gradle Wrapper takes build automation to another level - Gradle can, effectively, install itself.
  • 21. Install Gradle Wrapper ● Install the Wrapper into your project by running the wrapper task. (This task is always available, even if you don't add it to your build) gradle wrapper --gradle-version 2.0 Or task wrapper(type: Wrapper) { gradleVersion = '2.0' }