SlideShare une entreprise Scribd logo
1  sur  33
Gradle
1.What is this?
General purpose build system made in groovy that allows you to execute the needed commands to build software.
Manages:
- Build process
- Dependencies
- Project files
1.What is this?
Similar products:
- Ant
- Maven
- Gant
- Ivy
- Rake
- Buildr
- ...
1.What is this?
Big win
It is a full language itself, not a configuration file.
Gradle just provides a lifecycle and some classes to help you
2. How it works?
Manages with
some classes:
- Build process
- Dependencies
- Project files
USING
- Tasks
- Projects
- Repositories
- Dependencies
Key concepts:
- BuildScript
- Project
- Repositories
- Tasks
- Plugin
2. How it works?
BuildScript
2. How it works?
Setup script to add dependencies on the building
process. Ex. plugin dependencies
Project
2. How it works?
Element that represents the current project and is
considered the top level item. Contains all the
important information, plugins, files and source
directories.
Repositories
2. How it works?
Defines which are the sources of the possible
dependencies. Ex. MavenCentral, jCenter (bintray)
Tasks
2. How it works?
Pieces of code that are able to perform some action
defined. Tasks can be dependent from each other
and they can receive actions before or after.
Plugins
2. How it works?
Programs that evaluates during the build process
and are able to add behaviour and tasks to the
current project.
DSL based on Groovy but...
- You can do whatever you can do in the Groovy
language
- Use the DSL to make it look like a configuration
file
3. DSL Syntax
Class DSL
3. DSL Syntax
Class DSL
3. DSL Syntax
Class DSL
3. DSL Syntax
4. Build process lifecycle
- Compile build in .gradle cache
- Execute buildscript
- First round to configure dependencies and source directories
- afterEvaluate execution to generate tasks based on first step
- Execute whatever task you want
5. Task
Declare a task
5. Task
Add dependency between tasks
5. Task
- taks.doFirst
- task.doLast (<<)
- project.findBy..name, path...
- extend tasks
5. Task
Execute
./gradlew hello
hello
6. Plugins
apply plugin: "name"
where "name" is declared in META-INF in the plugin project.
Same as:
project.apply(MyPluginClass)
6. Plugins
public class MyPlugin extends Plugin<Project> {
@Override
public void apply(Project project){
}
}
7. Android plugin
- Android DSL
- Build types
- Flavors
- Dimensions
- Default configuration properties
7. Android plugin
Build type
- Application build configuration
- Default build types are debug and release
DSL: http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.BuildType.html
7. Android plugin
Flavor
- Specific files for the build
- Version code, variables, dimensions
- No needed/No default
DSL: http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.ProductFlavor.html
7. Android plugin
Dimension
- Mix different flavors in a single one
- Descriptor for a flavor
7. Android plugin
Is a = Flavor(s) + BuildType
Variant
Example
Build type: debug
Flavor: free
Tasks: installFreeDebug, assembleFreeDebug...
8. Show me the code
Default flavor without
name
Tell the compiler where to
find the tools in the
ANDROID_HOME
Plugin that defines the dsl (library and app)
8. Show me the code
- Searches on those repos defined in
repositories (jcenter, mavenCentral)
- Takes the group:artifact:version
- Allows to define dependencies inside the
project with plain jars
Black Magic with gradle
When integration with third parties sucks
Compiling libs per flavor
dependencies {
mppNotProductionCompile fileTree(dir: 'mppNonProd', include: '*.jar')
mppProductionCompile fileTree(dir: 'mppProd', include: '*.jar')
}
When third parties give several SDK per platform. As it is a dependency it’s an
unique, so values cannot override the others, you just need to choose what to
compile
Use resources per flavor
Usually you can define resources per flavor just making a folder matching the
flavor. In case you need to reuse in a different way you can iterate between flavors
in the sourceSets. For example:
[qaUat, qaApplauseTestersqa, qaMppQaAlpha].each { item ->
item.res.srcDirs = ['res_qa'] }
[prod, prodMppInt, prodMppPreprod, prodMppQa].each { item ->
item.res.srcDirs = ['res_prod'] }
Flavours to the infinity
The examples before were using 1 flavor to define free/paid and one for
buildType.
You can define as much as you want: flavorDimensions 'apptype', 'environment','mpayments'
This allows you combinations of:
apptype+environment+mpayments+buildType. BuildType is always the last.
The more flavorDimensions you have, the more number of variants you will be
able to create.

Contenu connexe

Tendances

Nakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - EnglishNakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - English
Svetlin Nakov
 
TestNG introduction
TestNG introductionTestNG introduction
TestNG introduction
Denis Bazhin
 

Tendances (20)

testng
testngtestng
testng
 
TypeScript and Angular workshop
TypeScript and Angular workshopTypeScript and Angular workshop
TypeScript and Angular workshop
 
Jenkins tutorial for beginners
Jenkins tutorial for beginnersJenkins tutorial for beginners
Jenkins tutorial for beginners
 
Nakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - EnglishNakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - English
 
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
 
Unit Testing with Jest
Unit Testing with JestUnit Testing with Jest
Unit Testing with Jest
 
Building with Gradle
Building with GradleBuilding with Gradle
Building with Gradle
 
TypeScript - An Introduction
TypeScript - An IntroductionTypeScript - An Introduction
TypeScript - An Introduction
 
Jenkins
JenkinsJenkins
Jenkins
 
Debugging in visual studio (basic level)
Debugging in visual studio (basic level)Debugging in visual studio (basic level)
Debugging in visual studio (basic level)
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
 
Java Unit Testing
Java Unit TestingJava Unit Testing
Java Unit Testing
 
Android activities & views
Android activities & viewsAndroid activities & views
Android activities & views
 
Introduction to Powershell Version 5
Introduction to Powershell Version 5Introduction to Powershell Version 5
Introduction to Powershell Version 5
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
Express js
Express jsExpress js
Express js
 
Angular modules in depth
Angular modules in depthAngular modules in depth
Angular modules in depth
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
 
TestNG introduction
TestNG introductionTestNG introduction
TestNG introduction
 

En vedette (7)

Gradle presentation
Gradle presentationGradle presentation
Gradle presentation
 
Android studio
Android studioAndroid studio
Android studio
 
Introduction to Android Studio
Introduction to Android StudioIntroduction to Android Studio
Introduction to Android Studio
 
Android studio 2.0
Android studio 2.0Android studio 2.0
Android studio 2.0
 
Android studio
Android studioAndroid studio
Android studio
 
Presentation on Android operating system
Presentation on Android operating systemPresentation on Android operating system
Presentation on Android operating system
 
Android ppt
Android ppt Android ppt
Android ppt
 

Similaire à Android presentation - Gradle ++

10 Cool Facts about Gradle
10 Cool Facts about Gradle10 Cool Facts about Gradle
10 Cool Facts about Gradle
Evgeny Goldin
 
Gradle - small introduction
Gradle - small introductionGradle - small introduction
Gradle - small introduction
Igor Popov
 

Similaire à Android presentation - Gradle ++ (20)

Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
 
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
 
ICONUK 2015 - Gradle Up!
ICONUK 2015 - Gradle Up!ICONUK 2015 - Gradle Up!
ICONUK 2015 - Gradle Up!
 
Node js Global Packages
Node js Global PackagesNode js Global Packages
Node js Global Packages
 
Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation Tool
 
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
 
CocoaPods.pptx
CocoaPods.pptxCocoaPods.pptx
CocoaPods.pptx
 
10 Cool Facts about Gradle
10 Cool Facts about Gradle10 Cool Facts about Gradle
10 Cool Facts about Gradle
 
Gradle - small introduction
Gradle - small introductionGradle - small introduction
Gradle - small introduction
 
Overview of Node JS
Overview of Node JSOverview of Node JS
Overview of Node JS
 
Gradle build capabilities
Gradle build capabilities Gradle build capabilities
Gradle build capabilities
 
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
 
Decrease build time and application size
Decrease build time and application sizeDecrease build time and application size
Decrease build time and application size
 
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]
 
Android app development lesson 1
Android app development lesson 1Android app development lesson 1
Android app development lesson 1
 
GradleFX
GradleFXGradleFX
GradleFX
 
Android gradle-build-system-overview
Android gradle-build-system-overviewAndroid gradle-build-system-overview
Android gradle-build-system-overview
 
Gradle
GradleGradle
Gradle
 
Mono Repo
Mono RepoMono Repo
Mono Repo
 

Dernier

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Dernier (20)

How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
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-...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
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
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
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...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%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
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
%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
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 

Android presentation - Gradle ++

  • 2. 1.What is this? General purpose build system made in groovy that allows you to execute the needed commands to build software. Manages: - Build process - Dependencies - Project files
  • 3. 1.What is this? Similar products: - Ant - Maven - Gant - Ivy - Rake - Buildr - ...
  • 4. 1.What is this? Big win It is a full language itself, not a configuration file. Gradle just provides a lifecycle and some classes to help you
  • 5. 2. How it works? Manages with some classes: - Build process - Dependencies - Project files USING - Tasks - Projects - Repositories - Dependencies
  • 6. Key concepts: - BuildScript - Project - Repositories - Tasks - Plugin 2. How it works?
  • 7. BuildScript 2. How it works? Setup script to add dependencies on the building process. Ex. plugin dependencies
  • 8. Project 2. How it works? Element that represents the current project and is considered the top level item. Contains all the important information, plugins, files and source directories.
  • 9. Repositories 2. How it works? Defines which are the sources of the possible dependencies. Ex. MavenCentral, jCenter (bintray)
  • 10. Tasks 2. How it works? Pieces of code that are able to perform some action defined. Tasks can be dependent from each other and they can receive actions before or after.
  • 11. Plugins 2. How it works? Programs that evaluates during the build process and are able to add behaviour and tasks to the current project.
  • 12. DSL based on Groovy but... - You can do whatever you can do in the Groovy language - Use the DSL to make it look like a configuration file 3. DSL Syntax
  • 16. 4. Build process lifecycle - Compile build in .gradle cache - Execute buildscript - First round to configure dependencies and source directories - afterEvaluate execution to generate tasks based on first step - Execute whatever task you want
  • 18. 5. Task Add dependency between tasks
  • 19. 5. Task - taks.doFirst - task.doLast (<<) - project.findBy..name, path... - extend tasks
  • 21. 6. Plugins apply plugin: "name" where "name" is declared in META-INF in the plugin project. Same as: project.apply(MyPluginClass)
  • 22. 6. Plugins public class MyPlugin extends Plugin<Project> { @Override public void apply(Project project){ } }
  • 23. 7. Android plugin - Android DSL - Build types - Flavors - Dimensions - Default configuration properties
  • 24. 7. Android plugin Build type - Application build configuration - Default build types are debug and release DSL: http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.BuildType.html
  • 25. 7. Android plugin Flavor - Specific files for the build - Version code, variables, dimensions - No needed/No default DSL: http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.ProductFlavor.html
  • 26. 7. Android plugin Dimension - Mix different flavors in a single one - Descriptor for a flavor
  • 27. 7. Android plugin Is a = Flavor(s) + BuildType Variant Example Build type: debug Flavor: free Tasks: installFreeDebug, assembleFreeDebug...
  • 28. 8. Show me the code Default flavor without name Tell the compiler where to find the tools in the ANDROID_HOME Plugin that defines the dsl (library and app)
  • 29. 8. Show me the code - Searches on those repos defined in repositories (jcenter, mavenCentral) - Takes the group:artifact:version - Allows to define dependencies inside the project with plain jars
  • 30. Black Magic with gradle When integration with third parties sucks
  • 31. Compiling libs per flavor dependencies { mppNotProductionCompile fileTree(dir: 'mppNonProd', include: '*.jar') mppProductionCompile fileTree(dir: 'mppProd', include: '*.jar') } When third parties give several SDK per platform. As it is a dependency it’s an unique, so values cannot override the others, you just need to choose what to compile
  • 32. Use resources per flavor Usually you can define resources per flavor just making a folder matching the flavor. In case you need to reuse in a different way you can iterate between flavors in the sourceSets. For example: [qaUat, qaApplauseTestersqa, qaMppQaAlpha].each { item -> item.res.srcDirs = ['res_qa'] } [prod, prodMppInt, prodMppPreprod, prodMppQa].each { item -> item.res.srcDirs = ['res_prod'] }
  • 33. Flavours to the infinity The examples before were using 1 flavor to define free/paid and one for buildType. You can define as much as you want: flavorDimensions 'apptype', 'environment','mpayments' This allows you combinations of: apptype+environment+mpayments+buildType. BuildType is always the last. The more flavorDimensions you have, the more number of variants you will be able to create.