gradle build automation tool
TRANSCRIPT
Gradlebuild automation tool
BJUG #27, november 2014Ioan Eugen Stan
About me
● independent IT Consultant (Java, Architecture)● Open Source Hacker● Web: http://ieugen.ro/● http://github.com/ieugen● @ieugen222Code: https://github.com/ieugen/bjug27-gradle-intro
Software development = creativity + lots of
repetive tasks
We hate repetitive tasks !!
We invented build tools ;)
A bit of build tool history
● shell scripts● simple tools: make, ant, etc ● tools with lifecycle: maven, gradle, etc.
Apache Ant
● like make, java oriented, multi-platform● has limited assumptions of build
environment● very flexible● imperative (no conventions)● lots of repetition● complex builds are hard to maintain● xml based configuration file
Apache Maven
● opinionated about the build lifecycle● introduced Convention over Configuration● strict lifecycle● java centric● limited flexibility in configuration● xml based configuration
Gradle● gradle uses build scripts: build.gradle● every build is a Groovy script● embraces Convention over Configuration and Don’t
Repeat Yourself● (almost) everything is convention and can be changed● creates a dynamic model of the workflow as a Directed
Acyclic Graph ~ DAG
Gradle features● declarative builds and build-by-convention● DSL for dependency based programming● structures your build● multi-project builds● gradle wrapper● build daemon - speeds build● many ways to manage dependencies● free and open-source
Maven build lifecycle - very strict
http://opensourceforgeeks.blogspot.ro/2014/01/building-java-projects-with-maven.html
Gradle build lifecycle
● Initialization○ identifies project to build○ creates Project instance
● Configuration○ executes buildscript{} for all its scope○ configures the project objects
● Execution○ creates the Task DAG○ runs the build
Task graphs (DAGs) java-plugin
Gradle Task
● single atomic piece of work for a build● belongs to a project● has properties● has a list of Actions
Invocation: gradle taskName
Dependencies code + demo
Build Daemoncode + demo
Usefull gradle pluginsCheck http://plugins.gradle.org/
and http://www.gradle.org/docs/current/userguide/standard_plugins
.html
References● Code: https://github.com/ieugen/bjug27-gradle-intro● UserGuide http://www.gradle.org/docs/current/userguide/userguide.html● DSL Reference http://www.gradle.org/docs/current/dsl/● Rocking the Gradle https://www.youtube.com/watch?v=5a91dBLX8Qc● Gradle intro https://www.youtube.com/watch?v=hvMKpQqo2ts