SlideShare a Scribd company logo
Gradle 2.
Breaking stereotypes.
Sergey Morenes, morenets@mail.ru
March, 26 2015
About author
• Works in IT since 2000
• 11 year of Java SE/EE experience
• Migrated to Gradle after 7 years of Ant/Maven
usage
• Regular speaker at Java conferences
Agenda
• Builds tools overview
• Gradle under the microscope
• Examples
• Q & A
Lost in selection
Magic pill
Apache Ant
• Offers extreme flexibility
• Imposes no convention
• Lightweight dependency management
Apache Ivy
• Cross-platform dependency management
• Transitive dependencies
• Enhanced support of repositories
Apache Maven
• Offers rigid standards and support for dependency
management
• More difficult and inflexible standards/procedures
• Declarative approach
Issue #1. XML
• Large and complex files are hard to understand
• Hierarchical structure limits the expressiveness
of the format
• Good format for the data and complex for the flow
Solution #1. Groovy
• An agile and dynamic language for the Java
Virtual Machine
• Makes modern programming features available to
Java developers with almost-zero learning curve
• Provides the ability to statically type
check and statically compile your code for
robustness and performance
• Share base syntax, type system, packages
hierarchy with Java
• Every Gradle build file is Groovy script
Gradle
• Flexible yet model-driven JVM-based build tool
• Acknowledges and improves on the very best ideas
from Make, Ant, Ivy, Maven, Rake, Gant, Scons, SBT,
Leinengen, and Buildr
Gradle
• First release in Apr 2008
• Current version 2.3 released in February 2015
• Used in Carrier, EADS, Hibernate, Grails, Groovy,
Spring-Security and Spring-Integration, Netflix,
LinkedIn
• Default build tool for Android OS
Hans Dockter
• Founder of Gradle and Gradleware
• 13 years of experience as a software developer,
team leader, architect, trainer, and mentor
• Previously worked at Jboss and founded Jboss-IDE
• Holds a Diploma in Physics with a minor in Computer
Science
• Admirer of domain-driven-design
Slogan
• Make the impossible possible
• Make the possible easy
• Make the easy elegant
Gradle overview
• A flexible general purpose build tool
• Declarative builds and build-by-convention plugins
on top
• Multi-project support
• Powerful dependency management based on Ivy
• Gradle is written in Java with a Groovy DSL layer on
top
• Programming tool
• Based on Groovy
Development
Version Release date
Maven 1.0 2004
Maven 2.0 2005
Maven 3.0 2010
Maven 3.1 2013
Maven 3.3 2015
Development
Version Release date
Gradle 0.7 2009
Gradle 1.0 2012
Gradle 1.5 2013
Gradle 2.0 2014
Gradle 2.3 2015
Build structure
• Gradle build consists of one or more projects
• Project contains one or more tasks
• Task is fundamental unit of build activity
• Tasks are named collections of build instructions
• Tasks are the equivalent to Ant targets
• Task is made up of actions
Hello world
$ gradle helloWorld
build.gradle
Maven pom
Dependencies
Dependencies
Properties
Properties
Build phases
Execution
Configuration
Initialization
Initialization
• Gradle defines which projects are involved in build
• Project instance is defined for each involved
project
Configuration
• Task objects are assembled into an internal object
model, usually called the DAG
• The build scripts of all projects which are part of the
build are executed
• If “configuration on demand” feature is enabled
then only relevant projects are configured
Execution
• Gradle determines the subset of the tasks, created
and configured during the configuration phase
• Subset of tasks depends on the gradle command
argument and the contents of the current directory.
• Selected tasks are executed in the order required
by their dependency relationships
DefaultTask
• dependsOn(task)
• doFirst(closure)
• doLast(closure)
• onlyIf(closure)
Sample project
Sample project
Dependent tasks
Custom task
• Writes audit information at the end of the build
• Audit information includes project name and build
timestamp
• Audit files are located in the separate folder
Custom task
Custom task
Custom task
Custom task
Multi-project builds
• Build where you build more than one project during
a single execution of Gradle
• Sub-projects should be defined in settings.gradle
• Settings file is analyzed in the initialization phase
when sub-projects are revealed and included into
DAG
• Sub-projects are sub-directories in the simplest case
settings.gradle
Plugin
• Reusable pieces of build logic
• Can be used in different projects/builds
• Can be written in Groovy, Java or Scala
Plugin
• Add tasks to the project
• Pre-configure added tasks with useful defaults
• Add dependency configurations to the project
• Add new properties and methods to existing type
via extensions
Plugins
• Android
• AspectJ
• Flex
• Grails
• GWT
• JavaScript
• JAXB
• Jenkins
• SvnKit
• Tomcat
• Xslt
Plugin import
Plugin portal
Plugin import
C++ support
Packaging
• Build script
• buildSrc project
• rootProjectDir/buildSrc/src/main/groovy
• Standalone project
Custom plugin
Custom plugin
Custom plugin
Custom plugin
• $ gradle writeBuild
Custom plugin
Integration
• Ant
• Maven
• Ivy
Gradle and Ant
• Gradle is often described as Groovy-based Ant.
• Competitor of Gant(Groovy Ant scripting)
• Share DAG concept
• Gradle tasks are similar to Ant targrets
• Gradle variables(typeless) are close to Ant
properties
Hello Ant
Ant import
Gradle and Maven
Gradle and Maven
Maven Coordinate Gradle Property Gradle Default
groupId group blank
artifactId name Project directory
name
version version unspecified
name N/A N/A
description description null
Comparison
Operation Gradle Maven
Build(sec) 21,2 24,2
Inc build(sec) 8,7 11
Build with
tests(sec)
29 28
Clean(sec) 3,9 3,1
Distributive(Mb) 44 3
Maven converter
• Create build.gradle file in the root folder
• Specify apply plugin: 'maven2Gradle' in the
build.gradle file.
• Run gradle maven2Gradle
Repositories
• Maven and Ivy support
Maven Scope
Maven Scope
Scopes:
• compile
• provided
• runtime
• test
• system
• import
Dependencies
Configurations
• compile
• default
• testCompile
• testRuntime
• archives
• runtime
Scope flexibility
Profiles
• build.gradle
• dev-profile.gradle
• test-profile.gradle
• $ gradle –Pprofile=dev build
Resource handling
Resource handling
Unit testing
• Junit
• TestNG
• Spock
• Geb
• EasyB
Skip tasks
• $ gradle -PskipTests
Skip tasks
Skip tasks
Caching
• Gradle caches all compiles scripts by default
• Compiled scripts are put into .gradle folder
• Gradle uses compiled version if the script hasn’t
changed
• --recompile-scripts option discards cache
GUI
Daemon
• Improves startup and execution time of Gradle
• Initial Gradle command forks daemon process
• Subsequent Gradle commands reuse the build
daemon
• If daemon is currently busy then new daemon
process is started on-demand
• Useful for small tasks execution
• Expires after 3 hours of idle time
Practical tasks
• Multiple projects
• Liquibase
• Deployment
Multiple projects
• Huge project
• Multiple sub-projects/pom.xml files
• Complicated maintenance
Liquibase
• Plugins for 2 and 3 versions
• Lightweight front-end for Liquibase command-line
• Gradle task for each Liquibase command
Deployment
• Separate plugins for Jetty/Tomcat
• General plugin for multiple containers
Cargo plugin
Cargo plugin
Pros
• Native Java support
• Ant/Maven integration
• Full IDE support
• Transitive dependency management(based on
Maven/Ivy)
• Multiple third-party plugins(70+)
• Incremental builds
• Rapid development
Cons
• Less efficient and possible compilation issues due to
script nature
• Large learning curve
• Less community & industry support
Future
• Testing toolkit for integration into business logic
• Improved plugin portal and plugin development
• Execution of Maven builds/plugins at runtime
• Distributed testing
• Parallel and distributed execution
… to be continued 
Resources
Practice
• https://github.com/hibernate/hibernate-orm
• https://github.com/SpringSource/spring-framework
• https://github.com/gradle/gradle
Q&A
• Сергей Моренец, morenets@mail.ru

More Related Content

PPTX
Gradle.Enemy at the gates
PPTX
Сергей Моренец: "Gradle. Write once, build everywhere"
PPTX
Gradle 2.Breaking stereotypes
PPTX
Git.From thorns to the stars
PPTX
Gradle 2.Write once, builde everywhere
PPTX
Top 10 reasons to migrate to Gradle
PPTX
PPTX
Why jakarta ee matters (ConFoo 2021)
Gradle.Enemy at the gates
Сергей Моренец: "Gradle. Write once, build everywhere"
Gradle 2.Breaking stereotypes
Git.From thorns to the stars
Gradle 2.Write once, builde everywhere
Top 10 reasons to migrate to Gradle
Why jakarta ee matters (ConFoo 2021)

What's hot (20)

PDF
Grails 3.0 Preview
PPTX
Database Migrations with Gradle and Liquibase
PPTX
Cucumber jvm best practices v3
PDF
Continuous integration and delivery for java based web applications
PDF
Gradle - Build system evolved
PPTX
Gradle build capabilities
PPTX
PPTX
Implementing FaaS on Kubernetes using Kubeless
PPTX
Google jib: Building Java containers without Docker
PPTX
Building with Gradle
PPTX
Overview of PaaS: Java experience
PDF
Apache DeltaSpike the CDI toolbox
PPTX
PPTX
Chef for DevOps - an Introduction
PDF
Gradle 3.0: Unleash the Daemon!
PPTX
Java 9 Module System Introduction
PPTX
Database CI/CD Pipeline
PPTX
Spring Framework 3.2 - What's New
PDF
How and why to upgrade to java 16 or 17
PDF
Javantura v4 - The power of cloud in professional services company - Ivan Krn...
Grails 3.0 Preview
Database Migrations with Gradle and Liquibase
Cucumber jvm best practices v3
Continuous integration and delivery for java based web applications
Gradle - Build system evolved
Gradle build capabilities
Implementing FaaS on Kubernetes using Kubeless
Google jib: Building Java containers without Docker
Building with Gradle
Overview of PaaS: Java experience
Apache DeltaSpike the CDI toolbox
Chef for DevOps - an Introduction
Gradle 3.0: Unleash the Daemon!
Java 9 Module System Introduction
Database CI/CD Pipeline
Spring Framework 3.2 - What's New
How and why to upgrade to java 16 or 17
Javantura v4 - The power of cloud in professional services company - Ivan Krn...
Ad

Similar to Gradle 2.breaking stereotypes. (20)

PPTX
Faster java ee builds with gradle [con4921]
PPTX
Faster Java EE Builds with Gradle
PPTX
Faster Java EE Builds with Gradle
PDF
Why gradle
PDF
Gradle
PDF
Hands on the Gradle
PDF
An Introduction to Gradle for Java Developers
ODP
Gradle - time for another build
PDF
ICONUK 2015 - Gradle Up!
PPTX
Hands on Gradle
PPTX
7 maven vsgradle
PDF
Enter the gradle
PDF
Gradle - time for a new build
PPT
An introduction to maven gradle and sbt
PDF
Enterprise build tool gradle
PDF
Introduction to gradle
PDF
PPTX
From Ant to Maven to Gradle a tale of CI tools for JVM
PDF
Gradle build automation tool
Faster java ee builds with gradle [con4921]
Faster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
Why gradle
Gradle
Hands on the Gradle
An Introduction to Gradle for Java Developers
Gradle - time for another build
ICONUK 2015 - Gradle Up!
Hands on Gradle
7 maven vsgradle
Enter the gradle
Gradle - time for a new build
An introduction to maven gradle and sbt
Enterprise build tool gradle
Introduction to gradle
From Ant to Maven to Gradle a tale of CI tools for JVM
Gradle build automation tool
Ad

More from Stfalcon Meetups (20)

PDF
Conversion centered design 3
PDF
Discovery phase
PPTX
Stfalcon QA Meetup 31.01.2020
PPTX
Stfalcon QA Meetup 31.01.2020
PDF
Stfalcon PM Meetup 21.11
PDF
Stfalcon PM Meetup 21.11
PDF
Design of the_future_30_05_2019
PPTX
2 5404811386729530203
PDF
Team evolution
PDF
Mobile&Privacy
PDF
Global sales - a few insights
PDF
How to build your own startup
PDF
Первая и последняя встреча с клиентом
PPTX
Парнерство нидерланды
ODP
Риси гарного менеджера
PPTX
Между заказчиком и разработчиком
PPTX
Cv vs resume
PPTX
PPTX
майстер-клас “Управління ризиками”
PPTX
Kubernetes: від знайомства до використання у CI/CD
Conversion centered design 3
Discovery phase
Stfalcon QA Meetup 31.01.2020
Stfalcon QA Meetup 31.01.2020
Stfalcon PM Meetup 21.11
Stfalcon PM Meetup 21.11
Design of the_future_30_05_2019
2 5404811386729530203
Team evolution
Mobile&Privacy
Global sales - a few insights
How to build your own startup
Первая и последняя встреча с клиентом
Парнерство нидерланды
Риси гарного менеджера
Между заказчиком и разработчиком
Cv vs resume
майстер-клас “Управління ризиками”
Kubernetes: від знайомства до використання у CI/CD

Recently uploaded (20)

PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Nekopoi APK 2025 free lastest update
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
System and Network Administraation Chapter 3
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
ISO 45001 Occupational Health and Safety Management System
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
medical staffing services at VALiNTRY
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
Odoo POS Development Services by CandidRoot Solutions
Nekopoi APK 2025 free lastest update
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
ManageIQ - Sprint 268 Review - Slide Deck
System and Network Administraation Chapter 3
Navsoft: AI-Powered Business Solutions & Custom Software Development
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
ISO 45001 Occupational Health and Safety Management System
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
How to Migrate SBCGlobal Email to Yahoo Easily
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
medical staffing services at VALiNTRY
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
CHAPTER 2 - PM Management and IT Context
Design an Analysis of Algorithms I-SECS-1021-03
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Design an Analysis of Algorithms II-SECS-1021-03
Adobe Illustrator 28.6 Crack My Vision of Vector Design
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
2025 Textile ERP Trends: SAP, Odoo & Oracle

Gradle 2.breaking stereotypes.