SlideShare a Scribd company logo
1 of 23
Download to read offline
Gradle v.1.0
Andrii Khaisin
Provectus IT
27.07.2013
About me
Senior Software Developer
at Provectus IT
for Men's Wearhouse
Gradle in a few words
• Gradle is task oriented build tool.
• Gradle has a set of default plugins which
define conventions and standard life cycle of
project build.
• Gradle build scripts are Groovy scripts which
customize default workflow for your needs.
• Gradle works well for Java projects and for
non Java projects as well.
What we need from a build tool
• Ability to create and support build scripts
• Ability to define projects hierarchy for multi
module build
• Ability to manage project dependencies
• Ability to implement custom build logic
• Ability to extend available plugins
• Ability to develop new own plugins
• Ability to support build configurations
Lets some practice
• Projects structure
• Build running
• Groovy is everywhere
• Tasks
• Plugin usage
• Repositories
• Dependencies
• Custom plugin
Projects structure
• Project object model
• Convention over configuration
• Customize project model with build.gradle
• Split big scripts into parts
• Put submodule related script into separate
file or keep everything in one file.
Projects structure example
project/
api/
src/
build.gradle
data/
src/
war/
src/
main/
test/
build.gradle
settings.gradle
Build running
Gradle Installing approaches
• Locally installed Gradle distribution
• Gradle Wrapper - Keep it with you project
and wrapper solve all other tasks as Gradle
version, downloading Gradle and etc.
• GVM - Groovy enVironment Manager
Gradle launch
gradle <params> [task1, [task2, taks3, ...]]
Groovy is everywhere
• Gradle scripts are Groovy scripts
• Gradle works in JVM
• All Java world in your hands
Groovy is everywhere example
// Somewhere in build.gradle
def env = System.getenv();
System.getenv().each {
println it
}
def user = env['USER'];
if (user != null) {
println "User: $user";
}
Tasks
• Task is a named piece of work
• Tasks have relations between each other
• Tasks creates steps by step process of
project build
Tasks example
def env;
def user;
task prepareEnv << {
env = System.getenv();
}
task prepareUser (dependsOn:
'prepareEnv') << {
user = env['USER'];
}
task printEnv (dependsOn: 'prepareEnv') << {
env.each {
println it
}
}
task printUser (dependsOn: 'prepareUser' ) << {
if (user != null) {
println "User: $user";
}
}
Plugins usage
1. Declare that certain plugin will be used
apply plugin: 'java' – adds Java lifecircle
2. Configure properties of this plugin
3. Launch task defined by this plugin
Java plugin and its tasks
Java plugin define set of tasks and dependencies between
the. In the way there is create lifecircle similar to lifecircle
available in Maven
Repositories
repositories {
mavenLocal()
mavenCentral()
mavenRepo name: "lib", url:"libs"
mavenRepo url: "http://repo.company.com/maven"
ivy {
url "http://repo.company.com/ivy"
}
// Any custom defined source of artifacts
}
Dependencies
• Dependency is described by group, name, version and
other optional attributes
• Dependency types are configurable by plugins
• Java plugin adds compile, runtime, testCompile,
testRuntime
• Gradle support dependency version ranges
• transitive dependency management
Dependencies example
allprojects {
dependencies {
compile ''commons-collections:commons-collections:3.1''
testCompile group: 'junit', name: 'junit', version: '4.+'
}
}
project(':api') {
dependencies {
compile ''javax.xml.ws:jaxws-api:$wsVersion''
}
}
project(':server') {
dependencies {
runtime ''com.sun.xml.ws:jaxws-rt:$wsVersion''
}
}
Custom plugins and tasks
There are places where custom plugins could
be stored:
• build.gradle
• apply from: 'other.gradle'
• buildSrc folder which is automatically used
as a sources of additional scripts
• Remotelocal repositories
Custom plugins - buildSrc
buildSrc/ - Additional module with build script sources
src/
main/
groovy/
Wsdl2JavaPlugin.groovy
test/
build.gradle - more configuration if needed
api/
data/
server/
build.gradle
settings.gradle
Custom plugins - wsdl2java
def class Wsdl2JavaPlugin implements Plugin<Project> {
void apply(Project project) {
// Take configuration of WSDL file path
// Inject task in build life cycle
project.tasks.processResources.dependsOn Wsdl2JavaTask
// Generate sources and add theirs folder to Sources Set
}
}
// Then somewhere in the project
project(':api') {
apply plugin: 'wsdl2java'
wsdl2java src:"api/src/main/resources/wsdl/Service.wsdl"
}
Gradle is
• powerful
• simple
• compact
• evolving
• possible to debug
Gradle is just fun!
That's all :)
Links
Build tools
• http://www.gradle.org/
• http://buildr.apache.org/
• http://rubyforge.org/projects/rake
• http://ant.apache.org/
• http://maven.apache.org/
• http://www.gnu.org/software/make/
• http://www.cmake.org/

More Related Content

What's hot

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
 
Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation ToolIzzet Mustafaiev
 
Gradle 3.0: Unleash the Daemon!
Gradle 3.0: Unleash the Daemon!Gradle 3.0: Unleash the Daemon!
Gradle 3.0: Unleash the Daemon!Eric Wendelin
 
Continuous Integration with Maven for Android apps
Continuous Integration with Maven for Android appsContinuous Integration with Maven for Android apps
Continuous Integration with Maven for Android appsHugo Josefson
 
"How to deploy to production 10 times a day" Андрей Шумада
"How to deploy to production 10 times a day" Андрей Шумада"How to deploy to production 10 times a day" Андрей Шумада
"How to deploy to production 10 times a day" Андрей ШумадаFwdays
 
Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new buildIgor Khotin
 
Build tools introduction
Build tools introductionBuild tools introduction
Build tools introductionvodQA
 
Jenkins Scriptler in 90mins
Jenkins Scriptler in 90minsJenkins Scriptler in 90mins
Jenkins Scriptler in 90minsLarry Cai
 
Jenkins Pipelining and Gatling Integration
Jenkins Pipelining and  Gatling IntegrationJenkins Pipelining and  Gatling Integration
Jenkins Pipelining and Gatling IntegrationKnoldus Inc.
 

What's hot (18)

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
 
Gradle
GradleGradle
Gradle
 
Gradle : An introduction
Gradle : An introduction Gradle : An introduction
Gradle : An introduction
 
Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation Tool
 
Session 2
Session 2Session 2
Session 2
 
Session 2
Session 2Session 2
Session 2
 
Integration testing dropwizard
Integration testing dropwizardIntegration testing dropwizard
Integration testing dropwizard
 
Gradle 3.0: Unleash the Daemon!
Gradle 3.0: Unleash the Daemon!Gradle 3.0: Unleash the Daemon!
Gradle 3.0: Unleash the Daemon!
 
Building with Gradle
Building with GradleBuilding with Gradle
Building with Gradle
 
Continuous Integration with Maven for Android apps
Continuous Integration with Maven for Android appsContinuous Integration with Maven for Android apps
Continuous Integration with Maven for Android apps
 
"How to deploy to production 10 times a day" Андрей Шумада
"How to deploy to production 10 times a day" Андрей Шумада"How to deploy to production 10 times a day" Андрей Шумада
"How to deploy to production 10 times a day" Андрей Шумада
 
Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new build
 
Build tools introduction
Build tools introductionBuild tools introduction
Build tools introduction
 
Jenkins Scriptler in 90mins
Jenkins Scriptler in 90minsJenkins Scriptler in 90mins
Jenkins Scriptler in 90mins
 
Jenkins Pipelining and Gatling Integration
Jenkins Pipelining and  Gatling IntegrationJenkins Pipelining and  Gatling Integration
Jenkins Pipelining and Gatling Integration
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
Ant, Maven and Jenkins
Ant, Maven and JenkinsAnt, Maven and Jenkins
Ant, Maven and Jenkins
 
Report portal
Report portalReport portal
Report portal
 

Viewers also liked

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
 
Docker containerization cookbook
Docker containerization cookbookDocker containerization cookbook
Docker containerization cookbookPascal Louis
 
Spring + JPA + DAO Step by Step
Spring + JPA + DAO Step by StepSpring + JPA + DAO Step by Step
Spring + JPA + DAO Step by StepGuo Albert
 
50 EJB 3 Best Practices in 50 Minutes - JavaOne 2014
50 EJB 3 Best Practices in 50 Minutes - JavaOne 201450 EJB 3 Best Practices in 50 Minutes - JavaOne 2014
50 EJB 3 Best Practices in 50 Minutes - JavaOne 2014Ryan Cuprak
 
Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Ryan Cuprak
 
Containerless in the Cloud with AWS Lambda
Containerless in the Cloud with AWS LambdaContainerless in the Cloud with AWS Lambda
Containerless in the Cloud with AWS LambdaRyan Cuprak
 
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...SlideShare
 

Viewers also liked (8)

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]
 
Dev ecosystem v1.1
Dev ecosystem v1.1Dev ecosystem v1.1
Dev ecosystem v1.1
 
Docker containerization cookbook
Docker containerization cookbookDocker containerization cookbook
Docker containerization cookbook
 
Spring + JPA + DAO Step by Step
Spring + JPA + DAO Step by StepSpring + JPA + DAO Step by Step
Spring + JPA + DAO Step by Step
 
50 EJB 3 Best Practices in 50 Minutes - JavaOne 2014
50 EJB 3 Best Practices in 50 Minutes - JavaOne 201450 EJB 3 Best Practices in 50 Minutes - JavaOne 2014
50 EJB 3 Best Practices in 50 Minutes - JavaOne 2014
 
Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]
 
Containerless in the Cloud with AWS Lambda
Containerless in the Cloud with AWS LambdaContainerless in the Cloud with AWS Lambda
Containerless in the Cloud with AWS Lambda
 
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
 

Similar to Gradle

Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolvedBhagwat Kumar
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulMert Çalışkan
 
Javaone - Gradle: Harder, Better, Stronger, Faster
Javaone - Gradle: Harder, Better, Stronger, Faster Javaone - Gradle: Harder, Better, Stronger, Faster
Javaone - Gradle: Harder, Better, Stronger, Faster Andres Almiray
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with GradleRyan 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
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenMert Çalışkan
 
An Introduction to Maven Part 1
An Introduction to Maven Part 1An Introduction to Maven Part 1
An Introduction to Maven Part 1MD Sayem Ahmed
 
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 sbtFabio Fumarola
 
AngularJS with RequireJS
AngularJS with RequireJSAngularJS with RequireJS
AngularJS with RequireJSJohannes Weber
 
(Re)-Introduction to Maven
(Re)-Introduction to Maven(Re)-Introduction to Maven
(Re)-Introduction to MavenEric Wyles
 
Play Support in Cloud Foundry
Play Support in Cloud FoundryPlay Support in Cloud Foundry
Play Support in Cloud Foundryrajdeep
 
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
 

Similar to Gradle (20)

Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolved
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
Javaone - Gradle: Harder, Better, Stronger, Faster
Javaone - Gradle: Harder, Better, Stronger, Faster Javaone - Gradle: Harder, Better, Stronger, Faster
Javaone - Gradle: Harder, Better, Stronger, Faster
 
Hands on the Gradle
Hands on the GradleHands on the Gradle
Hands on the Gradle
 
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
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Gradle - Build System
Gradle - Build SystemGradle - Build System
Gradle - Build System
 
Building with Gradle
Building with GradleBuilding with Gradle
Building with Gradle
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with Maven
 
Oracle 12c Launch Event 02 ADF 12c and Maven in Jdeveloper / By Aino Andriessen
Oracle 12c Launch Event 02 ADF 12c and Maven in Jdeveloper / By Aino Andriessen Oracle 12c Launch Event 02 ADF 12c and Maven in Jdeveloper / By Aino Andriessen
Oracle 12c Launch Event 02 ADF 12c and Maven in Jdeveloper / By Aino Andriessen
 
tools cli java
tools cli javatools cli java
tools cli java
 
An Introduction to Maven Part 1
An Introduction to Maven Part 1An Introduction to Maven Part 1
An Introduction to Maven Part 1
 
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
 
OpenCms Days 2012 - Developing OpenCms with Gradle
OpenCms Days 2012 - Developing OpenCms with GradleOpenCms Days 2012 - Developing OpenCms with Gradle
OpenCms Days 2012 - Developing OpenCms with Gradle
 
AngularJS with RequireJS
AngularJS with RequireJSAngularJS with RequireJS
AngularJS with RequireJS
 
(Re)-Introduction to Maven
(Re)-Introduction to Maven(Re)-Introduction to Maven
(Re)-Introduction to Maven
 
Play Support in Cloud Foundry
Play Support in Cloud FoundryPlay Support in Cloud Foundry
Play Support in Cloud Foundry
 
Maven
MavenMaven
Maven
 
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
 

Recently uploaded

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
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 educationjfdjdjcjdnsjd
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
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 REVIEWERMadyBayot
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
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 challengesrafiqahmad00786416
 
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 Takeoffsammart93
 
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 DiscoveryTrustArc
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 

Recently uploaded (20)

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
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
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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
 
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
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Gradle

  • 2. About me Senior Software Developer at Provectus IT for Men's Wearhouse
  • 3. Gradle in a few words • Gradle is task oriented build tool. • Gradle has a set of default plugins which define conventions and standard life cycle of project build. • Gradle build scripts are Groovy scripts which customize default workflow for your needs. • Gradle works well for Java projects and for non Java projects as well.
  • 4. What we need from a build tool • Ability to create and support build scripts • Ability to define projects hierarchy for multi module build • Ability to manage project dependencies • Ability to implement custom build logic • Ability to extend available plugins • Ability to develop new own plugins • Ability to support build configurations
  • 5. Lets some practice • Projects structure • Build running • Groovy is everywhere • Tasks • Plugin usage • Repositories • Dependencies • Custom plugin
  • 6. Projects structure • Project object model • Convention over configuration • Customize project model with build.gradle • Split big scripts into parts • Put submodule related script into separate file or keep everything in one file.
  • 8. Build running Gradle Installing approaches • Locally installed Gradle distribution • Gradle Wrapper - Keep it with you project and wrapper solve all other tasks as Gradle version, downloading Gradle and etc. • GVM - Groovy enVironment Manager Gradle launch gradle <params> [task1, [task2, taks3, ...]]
  • 9. Groovy is everywhere • Gradle scripts are Groovy scripts • Gradle works in JVM • All Java world in your hands
  • 10. Groovy is everywhere example // Somewhere in build.gradle def env = System.getenv(); System.getenv().each { println it } def user = env['USER']; if (user != null) { println "User: $user"; }
  • 11. Tasks • Task is a named piece of work • Tasks have relations between each other • Tasks creates steps by step process of project build
  • 12. Tasks example def env; def user; task prepareEnv << { env = System.getenv(); } task prepareUser (dependsOn: 'prepareEnv') << { user = env['USER']; } task printEnv (dependsOn: 'prepareEnv') << { env.each { println it } } task printUser (dependsOn: 'prepareUser' ) << { if (user != null) { println "User: $user"; } }
  • 13. Plugins usage 1. Declare that certain plugin will be used apply plugin: 'java' – adds Java lifecircle 2. Configure properties of this plugin 3. Launch task defined by this plugin
  • 14. Java plugin and its tasks Java plugin define set of tasks and dependencies between the. In the way there is create lifecircle similar to lifecircle available in Maven
  • 15. Repositories repositories { mavenLocal() mavenCentral() mavenRepo name: "lib", url:"libs" mavenRepo url: "http://repo.company.com/maven" ivy { url "http://repo.company.com/ivy" } // Any custom defined source of artifacts }
  • 16. Dependencies • Dependency is described by group, name, version and other optional attributes • Dependency types are configurable by plugins • Java plugin adds compile, runtime, testCompile, testRuntime • Gradle support dependency version ranges • transitive dependency management
  • 17. Dependencies example allprojects { dependencies { compile ''commons-collections:commons-collections:3.1'' testCompile group: 'junit', name: 'junit', version: '4.+' } } project(':api') { dependencies { compile ''javax.xml.ws:jaxws-api:$wsVersion'' } } project(':server') { dependencies { runtime ''com.sun.xml.ws:jaxws-rt:$wsVersion'' } }
  • 18. Custom plugins and tasks There are places where custom plugins could be stored: • build.gradle • apply from: 'other.gradle' • buildSrc folder which is automatically used as a sources of additional scripts • Remotelocal repositories
  • 19. Custom plugins - buildSrc buildSrc/ - Additional module with build script sources src/ main/ groovy/ Wsdl2JavaPlugin.groovy test/ build.gradle - more configuration if needed api/ data/ server/ build.gradle settings.gradle
  • 20. Custom plugins - wsdl2java def class Wsdl2JavaPlugin implements Plugin<Project> { void apply(Project project) { // Take configuration of WSDL file path // Inject task in build life cycle project.tasks.processResources.dependsOn Wsdl2JavaTask // Generate sources and add theirs folder to Sources Set } } // Then somewhere in the project project(':api') { apply plugin: 'wsdl2java' wsdl2java src:"api/src/main/resources/wsdl/Service.wsdl" }
  • 21. Gradle is • powerful • simple • compact • evolving • possible to debug Gradle is just fun!
  • 23. Links Build tools • http://www.gradle.org/ • http://buildr.apache.org/ • http://rubyforge.org/projects/rake • http://ant.apache.org/ • http://maven.apache.org/ • http://www.gnu.org/software/make/ • http://www.cmake.org/