SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Hands on Gradle
Mushfekur Rahman
Associate Software Engineer
Therap BD Ltd.
Why Build Systems?
• Your may need to share your code
• You may grow old and forget stuff
• IDEs change frequently
• Makes life easier
• Automate product development lifecycle
1. Validate
2. Compile
3. Test
4. Packaging (jar, war, ear, aar, apk…)
5. Deploy and/or Publish
What Are The Options?
• Ant
• Maven
• Gradle
Ant
• Stands for Another Neat Tool
• Evolved from *NIX based build utility make
• Pros
• Task based build lifecycle
• Concise build flow
• Cons
• Heavy XML (less maintainable)
• Hard to reuse
Maven
• Apache Project
• Pros
• Standard Project Structure
• Project signature
• Dependency Management
• Release and distribution management
• Cons
• Loads of XML
• Hard to implement custom behavior
Drum roll… Gradle!
• General purpose Java build tool
• Based on Groovy DSL (Domain Specific Language)
• Founder – Hans Dockter
• Maintained by Gradleware
• Free and open source (published under Apache License 2.0)
Why Gradle?
• Combines best of both worlds
• Task based build flow (remember Ant??)
• Robust dependency management (Maven)
• Convention over configuration
• Flexible, scalable, extensible
• Plugins
• Easy multi-project building
• Awesome documentation
Who uses Gradle?
Gradle Basics
• Installation
• Make sure you have Java (JRE)
• Download (http://www.gradle.org/downloads)
• Copy (/usr/local or C:UsersPublic)
• Add to system PATH (.bashrc, .bash_profile, environment variable)
• … and voila!
Gradle Basics
• Tasks
• Fundamental unit of build activity
• Tasks are Objects
• Every task is a subclass of DefaultTask (like java.lang.Object)
Gradle Basics (cont.)
• Properties of DefaultTask
• doFirst
• doLast
Gradle Basics (cont.)
• Task Dependency
• Links two tasks
• Used to create build lifecycle DAG
Gradle Basics (cont.)
• Plugins
• Collection of tasks
• Reusable piece of build script
• Example
• jar
• war
• android
Gradle Basics (cont.)
• Build lifecycle
1. Initialization
• Initializes scope of a build
• Identifies project environment
• e.g. single or multi-module
• Creates project instance
2. Configuration
• Configures project objects
3. Execution
• Determines subset of tasks
• Runs the build
Gradle Basics (cont.)
• Build scripts
• build.gradle
• settings.gradle (optional)
• gradle.properties (optional)
*Hopefully* Your First Gradle Build
• The Simplest Java Project (hello-gradle)
• Project layout
Hello Gradle!
• ‘java’ plugin
• http://www.gradle.org/docs/current/userguide/java_plugin.html
• Tasks
• Configure source set
• Dependency management
Java Plugin: Under The Hood
Building Web Apps
• Let’s make a currency converter - BDT to USD
• Project layout
Building Web Apps
• ‘war’ plugin
• Deploying our app
Building Android Apps
• Currency converter for android
• New android build system
• http://tools.android.com/tech-docs/new-build-system/
• Project layout
Building Android Apps (cont.)
• ‘android’ plugin
• http://tools.android.com/tech-docs/new-build-system/user-guide
• Tasks
• Packaging options
Gradle Wrapper
• How to manage gradle’s own version
• What if I don’t have gradle installed on my machine?

Weitere ähnliche Inhalte

Was ist angesagt?

Building next gen android library with gradle
Building next gen android library with gradleBuilding next gen android library with gradle
Building next gen android library with gradle
Anton Rutkevich
 

Was ist angesagt? (20)

Building next gen android library with gradle
Building next gen android library with gradleBuilding next gen android library with gradle
Building next gen android library with gradle
 
Ci of js and apex using jasmine, phantom js and drone io df14
Ci of js and apex using jasmine, phantom js and drone io   df14Ci of js and apex using jasmine, phantom js and drone io   df14
Ci of js and apex using jasmine, phantom js and drone io df14
 
Michael North "Ember.js 2 - Future-friendly ambitious apps, that scale!"
Michael North "Ember.js 2 - Future-friendly ambitious apps, that scale!"Michael North "Ember.js 2 - Future-friendly ambitious apps, that scale!"
Michael North "Ember.js 2 - Future-friendly ambitious apps, that scale!"
 
Being With Rails App For 3 Years
Being With Rails App For 3 YearsBeing With Rails App For 3 Years
Being With Rails App For 3 Years
 
Craft Beer & Clojure
Craft Beer & ClojureCraft Beer & Clojure
Craft Beer & Clojure
 
Android talks #08 decompiling android applications
Android talks #08   decompiling android applicationsAndroid talks #08   decompiling android applications
Android talks #08 decompiling android applications
 
I18nize Scala programs à la gettext
I18nize Scala programs à la gettextI18nize Scala programs à la gettext
I18nize Scala programs à la gettext
 
React Native
React NativeReact Native
React Native
 
Migrate PHP E-Commerce Site to Go
Migrate PHP E-Commerce Site to GoMigrate PHP E-Commerce Site to Go
Migrate PHP E-Commerce Site to Go
 
SGCE 2015 REST APIs
SGCE 2015 REST APIsSGCE 2015 REST APIs
SGCE 2015 REST APIs
 
Jasmine - A BDD test framework for JavaScript
Jasmine - A BDD test framework for JavaScriptJasmine - A BDD test framework for JavaScript
Jasmine - A BDD test framework for JavaScript
 
Agile sites311training
Agile sites311trainingAgile sites311training
Agile sites311training
 
React native: building native iOS apps with javascript
React native: building native iOS apps with javascriptReact native: building native iOS apps with javascript
React native: building native iOS apps with javascript
 
Ship It ! with Ruby/ Rails Ecosystem
Ship It ! with Ruby/ Rails EcosystemShip It ! with Ruby/ Rails Ecosystem
Ship It ! with Ruby/ Rails Ecosystem
 
ASP.NET MVC
ASP.NET MVCASP.NET MVC
ASP.NET MVC
 
Алексей Волков "Введение в React Native"
Алексей Волков "Введение в React Native"Алексей Волков "Введение в React Native"
Алексей Волков "Введение в React Native"
 
How to write a web framework
How to write a web frameworkHow to write a web framework
How to write a web framework
 
淺談 Startup 公司的軟體開發流程 v2
淺談 Startup 公司的軟體開發流程 v2淺談 Startup 公司的軟體開發流程 v2
淺談 Startup 公司的軟體開發流程 v2
 
ES2015 / ES6: Basics of modern Javascript
ES2015 / ES6: Basics of modern JavascriptES2015 / ES6: Basics of modern Javascript
ES2015 / ES6: Basics of modern Javascript
 
UPenn on Rails intro
UPenn on Rails introUPenn on Rails intro
UPenn on Rails intro
 

Ähnlich wie Hands on Gradle

Gradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypesGradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypes
Strannik_2013
 
Сергей Моренец: "Gradle. Write once, build everywhere"
Сергей Моренец: "Gradle. Write once, build everywhere"Сергей Моренец: "Gradle. Write once, build everywhere"
Сергей Моренец: "Gradle. Write once, build everywhere"
Provectus
 
Java Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.EasyJava Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.Easy
roialdaag
 

Ähnlich wie Hands on Gradle (20)

Gradle.Enemy at the gates
Gradle.Enemy at the gatesGradle.Enemy at the gates
Gradle.Enemy at the gates
 
Gradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypesGradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypes
 
Сергей Моренец: "Gradle. Write once, build everywhere"
Сергей Моренец: "Gradle. Write once, build everywhere"Сергей Моренец: "Gradle. Write once, build everywhere"
Сергей Моренец: "Gradle. Write once, build everywhere"
 
Gradle 2.Write once, builde everywhere
Gradle 2.Write once, builde everywhereGradle 2.Write once, builde everywhere
Gradle 2.Write once, builde everywhere
 
Gradle 2.breaking stereotypes.
Gradle 2.breaking stereotypes.Gradle 2.breaking stereotypes.
Gradle 2.breaking stereotypes.
 
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]
 
Tips For Maintaining OSS Projects
Tips For Maintaining OSS ProjectsTips For Maintaining OSS Projects
Tips For Maintaining OSS Projects
 
Exploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & BeyondExploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & Beyond
 
CT Software Developers Meetup: Using Docker and Vagrant Within A GitHub Pull ...
CT Software Developers Meetup: Using Docker and Vagrant Within A GitHub Pull ...CT Software Developers Meetup: Using Docker and Vagrant Within A GitHub Pull ...
CT Software Developers Meetup: Using Docker and Vagrant Within A GitHub Pull ...
 
Java Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.EasyJava Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.Easy
 
The Architect Way
The Architect WayThe Architect Way
The Architect Way
 
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
 
Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]
 
From Ant to Maven to Gradle a tale of CI tools for JVM
From Ant to Maven to Gradle a tale of CI tools for JVMFrom Ant to Maven to Gradle a tale of CI tools for JVM
From Ant to Maven to Gradle a tale of CI tools for JVM
 
JOSA TechTalks - Docker in Production
JOSA TechTalks - Docker in ProductionJOSA TechTalks - Docker in Production
JOSA TechTalks - Docker in Production
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
 
Gradle - Build System
Gradle - Build SystemGradle - Build System
Gradle - Build System
 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
 
Starting from scratch in 2017
Starting from scratch in 2017Starting from scratch in 2017
Starting from scratch in 2017
 

Mehr von Mushfekur Rahman (6)

An Automatic Method for Red-eye Detection and Correction in Digital Images
An Automatic Method for Red-eye Detection and Correction in Digital ImagesAn Automatic Method for Red-eye Detection and Correction in Digital Images
An Automatic Method for Red-eye Detection and Correction in Digital Images
 
Diagnosing HotSpot JVM Memory Leaks with JFR and JMC
Diagnosing HotSpot JVM Memory Leaks with JFR and JMCDiagnosing HotSpot JVM Memory Leaks with JFR and JMC
Diagnosing HotSpot JVM Memory Leaks with JFR and JMC
 
Building a Unified Logging Layer with Fluentd, Elasticsearch and Kibana
Building a Unified Logging Layer with Fluentd, Elasticsearch and KibanaBuilding a Unified Logging Layer with Fluentd, Elasticsearch and Kibana
Building a Unified Logging Layer with Fluentd, Elasticsearch and Kibana
 
Http Basics
Http BasicsHttp Basics
Http Basics
 
Distributed Transaction Management in Spring & JEE
Distributed Transaction Management in Spring & JEEDistributed Transaction Management in Spring & JEE
Distributed Transaction Management in Spring & JEE
 
Implementation of Election Algorithm of Distributed Systems in Client-Server ...
Implementation of Election Algorithm of Distributed Systems in Client-Server ...Implementation of Election Algorithm of Distributed Systems in Client-Server ...
Implementation of Election Algorithm of Distributed Systems in Client-Server ...
 

Kürzlich hochgeladen

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Kürzlich hochgeladen (20)

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 

Hands on Gradle

  • 1. Hands on Gradle Mushfekur Rahman Associate Software Engineer Therap BD Ltd.
  • 2. Why Build Systems? • Your may need to share your code • You may grow old and forget stuff • IDEs change frequently • Makes life easier • Automate product development lifecycle 1. Validate 2. Compile 3. Test 4. Packaging (jar, war, ear, aar, apk…) 5. Deploy and/or Publish
  • 3. What Are The Options? • Ant • Maven • Gradle
  • 4. Ant • Stands for Another Neat Tool • Evolved from *NIX based build utility make • Pros • Task based build lifecycle • Concise build flow • Cons • Heavy XML (less maintainable) • Hard to reuse
  • 5. Maven • Apache Project • Pros • Standard Project Structure • Project signature • Dependency Management • Release and distribution management • Cons • Loads of XML • Hard to implement custom behavior
  • 6. Drum roll… Gradle! • General purpose Java build tool • Based on Groovy DSL (Domain Specific Language) • Founder – Hans Dockter • Maintained by Gradleware • Free and open source (published under Apache License 2.0)
  • 7. Why Gradle? • Combines best of both worlds • Task based build flow (remember Ant??) • Robust dependency management (Maven) • Convention over configuration • Flexible, scalable, extensible • Plugins • Easy multi-project building • Awesome documentation
  • 9. Gradle Basics • Installation • Make sure you have Java (JRE) • Download (http://www.gradle.org/downloads) • Copy (/usr/local or C:UsersPublic) • Add to system PATH (.bashrc, .bash_profile, environment variable) • … and voila!
  • 10. Gradle Basics • Tasks • Fundamental unit of build activity • Tasks are Objects • Every task is a subclass of DefaultTask (like java.lang.Object)
  • 11. Gradle Basics (cont.) • Properties of DefaultTask • doFirst • doLast
  • 12. Gradle Basics (cont.) • Task Dependency • Links two tasks • Used to create build lifecycle DAG
  • 13. Gradle Basics (cont.) • Plugins • Collection of tasks • Reusable piece of build script • Example • jar • war • android
  • 14. Gradle Basics (cont.) • Build lifecycle 1. Initialization • Initializes scope of a build • Identifies project environment • e.g. single or multi-module • Creates project instance 2. Configuration • Configures project objects 3. Execution • Determines subset of tasks • Runs the build
  • 15. Gradle Basics (cont.) • Build scripts • build.gradle • settings.gradle (optional) • gradle.properties (optional)
  • 16. *Hopefully* Your First Gradle Build • The Simplest Java Project (hello-gradle) • Project layout
  • 17. Hello Gradle! • ‘java’ plugin • http://www.gradle.org/docs/current/userguide/java_plugin.html • Tasks • Configure source set • Dependency management
  • 18. Java Plugin: Under The Hood
  • 19. Building Web Apps • Let’s make a currency converter - BDT to USD • Project layout
  • 20. Building Web Apps • ‘war’ plugin • Deploying our app
  • 21. Building Android Apps • Currency converter for android • New android build system • http://tools.android.com/tech-docs/new-build-system/ • Project layout
  • 22. Building Android Apps (cont.) • ‘android’ plugin • http://tools.android.com/tech-docs/new-build-system/user-guide • Tasks • Packaging options
  • 23. Gradle Wrapper • How to manage gradle’s own version • What if I don’t have gradle installed on my machine?