SlideShare a Scribd company logo
1 of 22
Download to read offline
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

What's hot

What's hot (20)

Android presentation - Gradle ++
Android presentation - Gradle ++Android presentation - Gradle ++
Android presentation - Gradle ++
 
How to go about testing in React?
How to go about testing in React? How to go about testing in React?
How to go about testing in React?
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 
Angular 8
Angular 8 Angular 8
Angular 8
 
An Introduction To Jenkins
An Introduction To JenkinsAn Introduction To Jenkins
An Introduction To Jenkins
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete project
 
Jenkins tutorial
Jenkins tutorialJenkins tutorial
Jenkins tutorial
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
 
Java Class Loader
Java Class LoaderJava Class Loader
Java Class Loader
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Android Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndroid Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - Introduction
 
Angular
AngularAngular
Angular
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Spring Boot 3 And Beyond
Spring Boot 3 And BeyondSpring Boot 3 And Beyond
Spring Boot 3 And Beyond
 
Junit
JunitJunit
Junit
 
Tomcat server
 Tomcat server Tomcat server
Tomcat server
 
Server-side JS with NodeJS
Server-side JS with NodeJSServer-side JS with NodeJS
Server-side JS with NodeJS
 
Introduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platformIntroduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platform
 

Viewers also liked

Viewers also liked (17)

Introduction to es6
Introduction to es6Introduction to es6
Introduction to es6
 
Apache tika
Apache tikaApache tika
Apache tika
 
Cosmos DB Service
Cosmos DB ServiceCosmos DB Service
Cosmos DB Service
 
Actors model in gpars
Actors model in gparsActors model in gpars
Actors model in gpars
 
Jsoup
JsoupJsoup
Jsoup
 
Reactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaReactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJava
 
Unit test-using-spock in Grails
Unit test-using-spock in GrailsUnit test-using-spock in Grails
Unit test-using-spock in Grails
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Jmh
JmhJmh
Jmh
 
Introduction to thymeleaf
Introduction to thymeleafIntroduction to thymeleaf
Introduction to thymeleaf
 
Progressive Web-App (PWA)
Progressive Web-App (PWA)Progressive Web-App (PWA)
Progressive Web-App (PWA)
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
 
Spring Web Flow
Spring Web FlowSpring Web Flow
Spring Web Flow
 
JFree chart
JFree chartJFree chart
JFree chart
 
Grails with swagger
Grails with swaggerGrails with swagger
Grails with swagger
 
Hamcrest
HamcrestHamcrest
Hamcrest
 
Vertx
VertxVertx
Vertx
 

Similar to Introduction to gradle

Build your android app with gradle
Build your android app with gradleBuild your android app with gradle
Build your android app with gradle
Swain Loda
 

Similar to Introduction to gradle (20)

Gradle
GradleGradle
Gradle
 
Gradle,the new build system for android
Gradle,the new build system for androidGradle,the new build system for android
Gradle,the new build system for android
 
Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]
 
Gradle - Build System
Gradle - Build SystemGradle - Build System
Gradle - Build System
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
 
Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolved
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
 
Build your android app with gradle
Build your android app with gradleBuild your android app with gradle
Build your android app with gradle
 
Eclipse Buildship JUG Hamburg
Eclipse Buildship JUG HamburgEclipse Buildship JUG Hamburg
Eclipse Buildship JUG Hamburg
 
What's new in Gradle 4.0
What's new in Gradle 4.0What's new in Gradle 4.0
What's new in Gradle 4.0
 
ICONUK 2015 - Gradle Up!
ICONUK 2015 - Gradle Up!ICONUK 2015 - Gradle Up!
ICONUK 2015 - Gradle Up!
 
7 maven vsgradle
7 maven vsgradle7 maven vsgradle
7 maven vsgradle
 
Gradle : An introduction
Gradle : An introduction Gradle : An introduction
Gradle : An introduction
 
Gradle explained
Gradle explainedGradle explained
Gradle explained
 
Pragmatic software development in kdb+
Pragmatic software development in kdb+Pragmatic software development in kdb+
Pragmatic software development in kdb+
 
FOSDEM 2017: GitLab CI
FOSDEM 2017:  GitLab CIFOSDEM 2017:  GitLab CI
FOSDEM 2017: GitLab CI
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Gradle: One technology to build them all
Gradle: One technology to build them allGradle: One technology to build them all
Gradle: One technology to build them all
 
Gradle build capabilities
Gradle build capabilities Gradle build capabilities
Gradle build capabilities
 
Building a Drupal Distribution using Features, Drush Make, Installation Profi...
Building a Drupal Distribution using Features, Drush Make, Installation Profi...Building a Drupal Distribution using Features, Drush Make, Installation Profi...
Building a Drupal Distribution using Features, Drush Make, Installation Profi...
 

More from NexThoughts Technologies

More from NexThoughts Technologies (20)

Alexa skill
Alexa skillAlexa skill
Alexa skill
 
GraalVM
GraalVMGraalVM
GraalVM
 
Docker & kubernetes
Docker & kubernetesDocker & kubernetes
Docker & kubernetes
 
Apache commons
Apache commonsApache commons
Apache commons
 
HazelCast
HazelCastHazelCast
HazelCast
 
MySQL Pro
MySQL ProMySQL Pro
MySQL Pro
 
Microservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & ReduxMicroservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & Redux
 
Swagger
SwaggerSwagger
Swagger
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Arango DB
Arango DBArango DB
Arango DB
 
Jython
JythonJython
Jython
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
Smart Contract samples
Smart Contract samplesSmart Contract samples
Smart Contract samples
 
My Doc of geth
My Doc of gethMy Doc of geth
My Doc of geth
 
Geth important commands
Geth important commandsGeth important commands
Geth important commands
 
Ethereum genesis
Ethereum genesisEthereum genesis
Ethereum genesis
 
Ethereum
EthereumEthereum
Ethereum
 
Springboot Microservices
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
 
An Introduction to Redux
An Introduction to ReduxAn Introduction to Redux
An Introduction to Redux
 
Google authentication
Google authenticationGoogle authentication
Google authentication
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 

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' }