SlideShare una empresa de Scribd logo
1 de 22
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente (20)

The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6
 
Maven ppt
Maven pptMaven ppt
Maven ppt
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 
Core java
Core java Core java
Core java
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Ansible
AnsibleAnsible
Ansible
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJS
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Collection Framework in java
Collection Framework in javaCollection Framework in java
Collection Framework in java
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Webpack slides
Webpack slidesWebpack slides
Webpack slides
 
java 8 new features
java 8 new features java 8 new features
java 8 new features
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Javascript Module Patterns
Javascript Module PatternsJavascript Module Patterns
Javascript Module Patterns
 
Working with JSON
Working with JSONWorking with JSON
Working with JSON
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 

Destacado (16)

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
 
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 a Introduction to 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 androidzhang ghui
 
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]Ryan Cuprak
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with GradleRyan Cuprak
 
Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolvedBhagwat Kumar
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with GradleRyan Cuprak
 
Build your android app with gradle
Build your android app with gradleBuild your android app with gradle
Build your android app with gradleSwain Loda
 
Eclipse Buildship JUG Hamburg
Eclipse Buildship JUG HamburgEclipse Buildship JUG Hamburg
Eclipse Buildship JUG Hamburgsimonscholz
 
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.0Eric Wendelin
 
Pragmatic software development in kdb+
Pragmatic software development in kdb+Pragmatic software development in kdb+
Pragmatic software development in kdb+Ajay Rathore
 
FOSDEM 2017: GitLab CI
FOSDEM 2017:  GitLab CIFOSDEM 2017:  GitLab CI
FOSDEM 2017: GitLab CIOlinData
 
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 worldRoberto Pérez Alcolea
 
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 allBonitasoft
 

Similar a 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
 
Android presentation - Gradle ++
Android presentation - Gradle ++Android presentation - Gradle ++
Android presentation - Gradle ++
 
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
 

Más de 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
 

Último

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 DevelopmentsTrustArc
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 

Último (20)

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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 

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