The document discusses Gradle, an open-source build automation tool. It provides an overview of Gradle, including its key features like flexible configuration, Groovy DSL, and improvements on Ant, Maven, and Ivy. The document also covers Gradle basics like projects, tasks, dependencies, plugins, testing and more. It compares Gradle to Maven and Ant and discusses how to integrate with them. The author concludes with pros and cons of Gradle along with its future outlook.
2. 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
6. Apache Ant
• Offers extreme flexibility
• Imposes no convention
• Lightweight dependency management
7. Apache Ivy
• Cross-platform dependency management
• Transitive dependencies
• Enhanced support of repositories
8. Apache Maven
• Offers rigid standards and support for dependency
management
• More difficult and inflexible standards/procedures
• Declarative approach
9. 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
10. 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
11. 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
12. 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
13. 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
14. Slogan
• Make the impossible possible
• Make the possible easy
• Make the easy elegant
15. 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
18. 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
28. Initialization
• Gradle defines which projects are involved in build
• Project instance is defined for each involved
project
29. 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
30. 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
35. 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
38. 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
43. 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
44. Plugin
• Reusable pieces of build logic
• Can be used in different projects/builds
• Can be written in Groovy, Java or Scala
45. 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
53. 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
57. 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
60. Maven converter
• Create build.gradle file in the root folder
• Specify apply plugin: 'maven2Gradle' in the
build.gradle file.
• Run gradle maven2Gradle
73. 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
81. 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
82. Cons
• Less efficient and possible compilation issues due to
script nature
• Large learning curve
• Less community & industry support
83. 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