SlideShare a Scribd company logo
1 of 49
Download to read offline
GRADLE IN 45MIN
Schalk Cronjé
ABOUT ME
Email:
Twitter / Ello : @ysb33r
ysb33r@gmail.com
Gradle plugins authored/contributed to: VFS, Asciidoctor,
JRuby family (base, jar, war etc.), GnuMake, Doxygen
GET YOUR DAILY GRADLE DOSE
@DailyGradle
#gradleTip
GRADLE
A next generation build-and-deploy
pipeline tool
MOST TRIVIAL JAVA PROJECT
apply plugin: 'java'
Will look for sources under src/main/java
JAVA PROJECT
repositories {
jcenter()
}
apply plugin : 'java'
dependencies {
testCompile 'junit:junit:4.1'
}
GRADLE DEPENDENCY
MANAGEMENT
Easy to use
Flexible to configure for exceptions
Uses dependencies closure
First word on line is usually name of a configuration.
Configurations are usually supplied by plugins.
Dependencies are downloaded from repositories
Maven coordinates are used as format
GRADLE REPOSITORIES
Specified within a repositories closure
Processed in listed order to look for dependencies
jcenter() preferred open-source repo.
mavenLocal(), mavenCentral(), maven {}
Ivy repositories via ivy {}
Flat-directory repositories via flatDir
GRADLE REPOSITORIES
repositories {
jcenter()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
repositories {
ivy {
url 'file://path/to/repo'
layout 'pattern', {
artifact '[module]/[revision]/[artifact](.[ext])'
ivy '[module]/[revision]/ivy.xml'
}
}
}
GRADLE DSL
Underlying language is Groovy
You don’t need to be a Groovy expert to be a Gradle power
user
Groovy doesn’t need ; in most cases
Groovy does more with less punctuation, making it an
ideal choice for a DSL
In most cases lines that do not end on an operator is
considered a completed statement.
GROOVY VS JAVA
In Groovy:
All class members are public by default
No need to create getters/setters for public fields
Both static & dynamic typing supported
def means Object
CALLING METHODS
class Foo {
void bar( def a,def b ) {}
}
def foo = new Foo()
foo.bar( '123',456 )
foo.bar '123', 456
foo.with {
bar '123', 456
}
CALLING METHODS WITH CLOSURES
class Foo {
void bar( def a,Closure b ) {}
}
def foo = new Foo()
foo.bar( '123',{ println it } )
foo.bar ('123') {
println it
}
foo.bar '123', {
println it
}
MAPS IN GROOVY
Hashmaps in Groovy are simple to use
def myMap = [ plugin : 'java' ]
Maps are easy to pass inline to functions
project.apply( plugin : 'java' )
Which in Gradle can become
apply plugin : 'java'
LISTS IN GROOVY
Lists in Groovy are simple too
def myList = [ 'clone', ''http://github.com/ysb33r/GradleLectures' ]
This makes it possible for Gradle to do
args 'clone', 'http://github.com/ysb33r/GradleLectures'
CLOSURE DELEGATION IN GROOVY
When a symbol cannot be resolved within a closure,
Groovy will look elsewhere
In Groovy speak this is called a Delegate.
This can be programmatically controlled via the
Closure.delegate property.
CLOSURE DELEGATION IN GROOVY
class Foo {
def target
}
class Bar {
Foo foo = new Foo()
void doSomething( Closure c ) {
c.delegate = foo
c()
}
}
Bar bar = new Bar()
bar.doSomething {
target = 10
}
MORE CLOSURE MAGIC
If a Groovy class has a method 'call(Closure)`, the object can
be passed a closure directly.
class Foo {
def call( Closure c) { /* ... */ }
}
Foo foo = new Foo()
foo {
println 'Hello, world'
}
// This avoids ugly syntax
foo.call({ println 'Hello, world' })
CLOSURE DELEGATION IN GRADLE
In most cases the delegation will be entity the closure is
passed to.
Will also look at the Project and ext objects.
The Closure.delegate property allows plugin writers
ability to create beautiful DSLs
task runSomething(type : Exec ) { cmdline 'git' }
is roughly the equivalent of
ExecTask runSomething = new ExecTask()
runSomething.cmdline( 'git' )
GRADLE TASKS
Can be based upon a task type
task runSomething ( type : Exec ) {
command 'git'
args 'clone', 'https://bitbucket.com/ysb33r/GradleWorkshop'
}
Can be free-form
task hellowWorld << {
println 'Hello, world'
}
GRADLE TASKS : CONFIGURATION VS
ACTION
Use of << {} adds action to be executed
Tasks supplied by plugin will have default actions
Use of {} configures a task
BUILDSCRIPT
The buildscript closure is special
It tells Gradle what to load into the classpath before
evaluating the script itself.
It also tells it where to look for those dependencies.
Even though Gradle 2.1 has added a new way of adding
external plugins, buildscript are much more flexible.
EXTENSIONS
Extensions are global configuration blocks added by
plugins.
Example: The jruby-gradle-base plugin will add a
jruby block.
apply plugin: 'com.github.jruby-gradle.base'
jruby {
defaultVersion = '1.7.11'
}
GRADLE COMMAND-LINE
gradle -v
gradle -h
gradle tasks
gradle tasks --info
GRADLE WRAPPER
Use wrapper where possible:
Eliminates need to install Gradle in order to build project
Leads to more reproducible builds
gradle wrapper --wrapper-version 2.12
./gradlew tasks
EXECUTING TASKS
./gradlew <taskName1> <taskName2> ...
./gradlew build
DEPENDENCIES
Examine dependencies involved with various configurations
./gradlew dependencies
SUPPORT FOR OTHER JVM
LANGUAGES
GROOVY PROJECT
repositories {
jcenter()
}
apply plugin : 'groovy'
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.3'
testCompile ('org.spockframework:spock-core:1.0-groovy-2.4') {
exclude module : 'groovy-all'
}
}
SCALA PROJECT
repositories {
jcenter()
}
apply plugin : 'scala'
dependencies {
compile 'org.scala-lang:scala-library:2.11.8'
}
BUILDING KOTLIN
plugins {
id "com.zoltu.kotlin" version "1.0.1"
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:1.0.1-1"
}
RUNNING JRUBY
plugins {
id 'com.github.jruby-gradle.base' version '1.2.1'
}
import com.github.jrubygradle.JRubyExec
dependencies {
jrubyExec "rubygems:colorize:0.7.7"
}
task printSomePrettyOutputPlease(type: JRubyExec) {
description "Execute our nice local print-script.rb"
script "${projectDir}/print-script.rb"
}
(Example from JRuby-Gradle project)
OTHER LANGUAGES
C++ / C / ASM / Resources (built-in)
Clojure (plugin)
Frege (plugin)
Golang (plugin)
Gosu (plugin)
Mirah (plugin in progress)
SUPPORT FOR OTHER
BUILDSYSTEMS
ANT (built-in)
GNU Make
MSBuild / xBuild
Grunt, Gulp
Anything else cra able via Exec or JavaExec task
BUILDING DOCUMENTATION
Javadoc, Groovydoc, Scaladoc (built-in)
Doxygen (C, C++) (plugin)
Markdown (plugin)
Asciidoctor (plugin)
BUILDING WITH ASCIIDOCTOR
plugins {
id 'org.asciidoctor.convert' version '1.5.2'
}
BUILDING WITH ASCIIDOCTOR
repositories {
jcenter()
}
asciidoctor {
sources {
include 'example.adoc'
}
backends 'html5'
}
PUBLISHING
Built-in to Maven, Ivy
Metadata publishing for native projects still lacking
Various plugins for AWS and other cloud storage
Plain old copies to FTP, SFTP etc.
MORE SUPPORT…
Official buildsystem for Android
Docker
Hadoop
TOUR DE FORCE
Build a distributable application packaged as as ZIP
Runnable via shell script or batch file
Contains classes written Java, Groovy & Kotlin source
Test source code with Spock Framework
TOUR DE FORCE
plugins {
id 'java'
id 'groovy'
id 'com.zoltu.kotlin' version '1.0.1'
id 'application'
}
repositories {
jcenter()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.3'
compile 'org.jetbrains.kotlin:kotlin-stdlib:1.0.1-1'
testCompile 'org.spockframework:spock-core:1.0-groovy-2.4'
}
version = '1.0'
mainClassName = "gradle.workshop.HelloJava"
compileGroovy.dependsOn compileKotlin
ENDGAME
Gradle is breaking new ground
Ever improving native support
Continuous performance improvements
Go find some more plugins at https://plugins.gradle.org
ABOUT THIS PRESENTATION
Written in Asciidoctor
Styled by asciidoctor-revealjs extension
Built using:
Gradle
gradle-asciidoctor-plugin
gradle-vfs-plugin
Code snippets tested as part of build
Source code:
https://github.com/ysb33r/GradleLectures/tree/MkJugMar201
THANK YOU
Email:
Twitter / Ello : @ysb33r
#idiomaticgradle
ysb33r@gmail.com
https://leanpub.com/idiomaticgradle
MIGRATIONS
ANT TO GRADLE
Reflect Ant Build into Gradle
ant.importBuild('build.xml')
MAVEN TO GRADLE
Go to directory where pom.xml is and type
gradle init --type pom
USEFUL STUFF
PUBLISHING VIA VFS
plugins {
id "org.ysb33r.vfs" version "1.0-beta3"
}
task publishToWebserver << {
vfs {
cp "${buildDir}/website",
"ftp://${username}:${password}@int.someserver.com/var/www",
recursive : true, overwrite : true
}
}

More Related Content

What's hot

Cool Jvm Tools to Help you Test - Aylesbury Testers Version
Cool Jvm Tools to Help you Test - Aylesbury Testers VersionCool Jvm Tools to Help you Test - Aylesbury Testers Version
Cool Jvm Tools to Help you Test - Aylesbury Testers VersionSchalk Cronjé
 
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...ZeroTurnaround
 
Managing dependencies with gradle
Managing dependencies with gradleManaging dependencies with gradle
Managing dependencies with gradleLiviu Tudor
 
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
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersKostas Saidis
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingSchalk Cronjé
 
The world of gradle - an introduction for developers
The world of gradle  - an introduction for developersThe world of gradle  - an introduction for developers
The world of gradle - an introduction for developersTricode (part of Dept)
 
うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-kyon mm
 
Gradle plugins, take it to the next level
Gradle plugins, take it to the next levelGradle plugins, take it to the next level
Gradle plugins, take it to the next levelEyal Lezmy
 
Gradle - time for another build
Gradle - time for another buildGradle - time for another build
Gradle - time for another buildIgor Khotin
 
In the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleIn the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleSkills Matter
 
Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!Corneil du Plessis
 

What's hot (20)

Cool Jvm Tools to Help you Test - Aylesbury Testers Version
Cool Jvm Tools to Help you Test - Aylesbury Testers VersionCool Jvm Tools to Help you Test - Aylesbury Testers Version
Cool Jvm Tools to Help you Test - Aylesbury Testers Version
 
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
Managing dependencies with gradle
Managing dependencies with gradleManaging dependencies with gradle
Managing dependencies with gradle
 
Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation Tool
 
Gradle 3.0: Unleash the Daemon!
Gradle 3.0: Unleash the Daemon!Gradle 3.0: Unleash the Daemon!
Gradle 3.0: Unleash the Daemon!
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java Developers
 
Gradle
GradleGradle
Gradle
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
 
The world of gradle - an introduction for developers
The world of gradle  - an introduction for developersThe world of gradle  - an introduction for developers
The world of gradle - an introduction for developers
 
Android presentation - Gradle ++
Android presentation - Gradle ++Android presentation - Gradle ++
Android presentation - Gradle ++
 
Gradle : An introduction
Gradle : An introduction Gradle : An introduction
Gradle : An introduction
 
うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-
 
Gradle plugins, take it to the next level
Gradle plugins, take it to the next levelGradle plugins, take it to the next level
Gradle plugins, take it to the next level
 
Gradle - time for another build
Gradle - time for another buildGradle - time for another build
Gradle - time for another build
 
Gradle presentation
Gradle presentationGradle presentation
Gradle presentation
 
In the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleIn the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: Gradle
 
Hands on the Gradle
Hands on the GradleHands on the Gradle
Hands on the Gradle
 
Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!
 
Gradle como alternativa a maven
Gradle como alternativa a mavenGradle como alternativa a maven
Gradle como alternativa a maven
 

Viewers also liked

Intro to CI/CD using Docker
Intro to CI/CD using DockerIntro to CI/CD using Docker
Intro to CI/CD using DockerMichael Irwin
 
What's New in Docker 1.13?
What's New in Docker 1.13?What's New in Docker 1.13?
What's New in Docker 1.13?Michael Irwin
 
Making a small QA system with Docker
Making a small QA system with DockerMaking a small QA system with Docker
Making a small QA system with DockerNaoki AINOYA
 
Captain Agile and the Providers of Value
Captain Agile and the Providers of ValueCaptain Agile and the Providers of Value
Captain Agile and the Providers of ValueSchalk Cronjé
 
Alpes Jug (29th March, 2010) - Apache Maven
Alpes Jug (29th March, 2010) - Apache MavenAlpes Jug (29th March, 2010) - Apache Maven
Alpes Jug (29th March, 2010) - Apache MavenArnaud Héritier
 
20091112 - Mars Jug - Apache Maven
20091112 - Mars Jug - Apache Maven20091112 - Mars Jug - Apache Maven
20091112 - Mars Jug - Apache MavenArnaud Héritier
 
Building Android apps with Maven
Building Android apps with MavenBuilding Android apps with Maven
Building Android apps with MavenFabrizio Giudici
 
Veni, Vide, Built: Android Gradle Plugin
Veni, Vide, Built: Android Gradle PluginVeni, Vide, Built: Android Gradle Plugin
Veni, Vide, Built: Android Gradle PluginLeonardo YongUk Kim
 
Gradle enabled android project
Gradle enabled android projectGradle enabled android project
Gradle enabled android projectShaka Huang
 
不只自動化而且更敏捷的Android開發工具 gradle mopcon
不只自動化而且更敏捷的Android開發工具 gradle mopcon不只自動化而且更敏捷的Android開發工具 gradle mopcon
不只自動化而且更敏捷的Android開發工具 gradle mopconsam chiu
 
Lorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - MavenLorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - MavenArnaud Héritier
 
Pluggable Infrastructure with CI/CD and Docker
Pluggable Infrastructure with CI/CD and DockerPluggable Infrastructure with CI/CD and Docker
Pluggable Infrastructure with CI/CD and DockerBob Killen
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Carlos Sanchez
 
Gradle talk, Javarsovia 2010
Gradle talk, Javarsovia 2010Gradle talk, Javarsovia 2010
Gradle talk, Javarsovia 2010Tomek Kaczanowski
 
Mastering Maven 2.0 In 1 Hour V1.3
Mastering Maven 2.0 In 1 Hour V1.3Mastering Maven 2.0 In 1 Hour V1.3
Mastering Maven 2.0 In 1 Hour V1.3Matthew McCullough
 
Drupal Continuous Integration with Jenkins - The Basics
Drupal Continuous Integration with Jenkins - The BasicsDrupal Continuous Integration with Jenkins - The Basics
Drupal Continuous Integration with Jenkins - The BasicsJohn Smith
 

Viewers also liked (20)

Intro to CI/CD using Docker
Intro to CI/CD using DockerIntro to CI/CD using Docker
Intro to CI/CD using Docker
 
What's New in Docker 1.13?
What's New in Docker 1.13?What's New in Docker 1.13?
What's New in Docker 1.13?
 
Making a small QA system with Docker
Making a small QA system with DockerMaking a small QA system with Docker
Making a small QA system with Docker
 
Git,Travis,Gradle
Git,Travis,GradleGit,Travis,Gradle
Git,Travis,Gradle
 
Captain Agile and the Providers of Value
Captain Agile and the Providers of ValueCaptain Agile and the Providers of Value
Captain Agile and the Providers of Value
 
Alpes Jug (29th March, 2010) - Apache Maven
Alpes Jug (29th March, 2010) - Apache MavenAlpes Jug (29th March, 2010) - Apache Maven
Alpes Jug (29th March, 2010) - Apache Maven
 
20091112 - Mars Jug - Apache Maven
20091112 - Mars Jug - Apache Maven20091112 - Mars Jug - Apache Maven
20091112 - Mars Jug - Apache Maven
 
Building Android apps with Maven
Building Android apps with MavenBuilding Android apps with Maven
Building Android apps with Maven
 
Maven 3.0 at Øredev
Maven 3.0 at ØredevMaven 3.0 at Øredev
Maven 3.0 at Øredev
 
Veni, Vide, Built: Android Gradle Plugin
Veni, Vide, Built: Android Gradle PluginVeni, Vide, Built: Android Gradle Plugin
Veni, Vide, Built: Android Gradle Plugin
 
Gradle enabled android project
Gradle enabled android projectGradle enabled android project
Gradle enabled android project
 
不只自動化而且更敏捷的Android開發工具 gradle mopcon
不只自動化而且更敏捷的Android開發工具 gradle mopcon不只自動化而且更敏捷的Android開發工具 gradle mopcon
不只自動化而且更敏捷的Android開發工具 gradle mopcon
 
Gradle
GradleGradle
Gradle
 
Lorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - MavenLorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - Maven
 
Pluggable Infrastructure with CI/CD and Docker
Pluggable Infrastructure with CI/CD and DockerPluggable Infrastructure with CI/CD and Docker
Pluggable Infrastructure with CI/CD and Docker
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
 
Gradle talk, Javarsovia 2010
Gradle talk, Javarsovia 2010Gradle talk, Javarsovia 2010
Gradle talk, Javarsovia 2010
 
Gradle
GradleGradle
Gradle
 
Mastering Maven 2.0 In 1 Hour V1.3
Mastering Maven 2.0 In 1 Hour V1.3Mastering Maven 2.0 In 1 Hour V1.3
Mastering Maven 2.0 In 1 Hour V1.3
 
Drupal Continuous Integration with Jenkins - The Basics
Drupal Continuous Integration with Jenkins - The BasicsDrupal Continuous Integration with Jenkins - The Basics
Drupal Continuous Integration with Jenkins - The Basics
 

Similar to Gradle in 45min

Gradle in a Polyglot World
Gradle in a Polyglot WorldGradle in a Polyglot World
Gradle in a Polyglot WorldSchalk Cronjé
 
Anatomy of a Gradle plugin
Anatomy of a Gradle pluginAnatomy of a Gradle plugin
Anatomy of a Gradle pluginDmytro Zaitsev
 
Grails Plugin
Grails PluginGrails Plugin
Grails Pluginguligala
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyDavid Padbury
 
Building scala with bazel
Building scala with bazelBuilding scala with bazel
Building scala with bazelNatan Silnitsky
 
Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017Andres Almiray
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingSchalk Cronjé
 
Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017Andres Almiray
 
Griffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java TechnologyGriffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java TechnologyJames Williams
 
Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01Tino Isnich
 
Gradle - small introduction
Gradle - small introductionGradle - small introduction
Gradle - small introductionIgor Popov
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingSchalk Cronjé
 
Groovy Grails Gr8Ladies Women Techmakers: Minneapolis
Groovy Grails Gr8Ladies Women Techmakers: MinneapolisGroovy Grails Gr8Ladies Women Techmakers: Minneapolis
Groovy Grails Gr8Ladies Women Techmakers: MinneapolisJenn Strater
 
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
 

Similar to Gradle in 45min (20)

Gradle in a Polyglot World
Gradle in a Polyglot WorldGradle in a Polyglot World
Gradle in a Polyglot World
 
Anatomy of a Gradle plugin
Anatomy of a Gradle pluginAnatomy of a Gradle plugin
Anatomy of a Gradle plugin
 
Enter the gradle
Enter the gradleEnter the gradle
Enter the gradle
 
GradleFX
GradleFXGradleFX
GradleFX
 
Grails Plugin
Grails PluginGrails Plugin
Grails Plugin
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
 
Building scala with bazel
Building scala with bazelBuilding scala with bazel
Building scala with bazel
 
Why gradle
Why gradle Why gradle
Why gradle
 
Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
 
Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017
 
Griffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java TechnologyGriffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java Technology
 
Griffon Presentation
Griffon PresentationGriffon Presentation
Griffon Presentation
 
Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01
 
Gradle - small introduction
Gradle - small introductionGradle - small introduction
Gradle - small introduction
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
 
Groovy Grails Gr8Ladies Women Techmakers: Minneapolis
Groovy Grails Gr8Ladies Women Techmakers: MinneapolisGroovy Grails Gr8Ladies Women Techmakers: Minneapolis
Groovy Grails Gr8Ladies Women Techmakers: Minneapolis
 
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
 
What's New in Groovy 1.6?
What's New in Groovy 1.6?What's New in Groovy 1.6?
What's New in Groovy 1.6?
 

More from Schalk Cronjé

DocuOps & Asciidoctor in a JVM World
DocuOps & Asciidoctor in a JVM WorldDocuOps & Asciidoctor in a JVM World
DocuOps & Asciidoctor in a JVM WorldSchalk Cronjé
 
What's new in Asciidoctor
What's new in AsciidoctorWhat's new in Asciidoctor
What's new in AsciidoctorSchalk Cronjé
 
Probability Management
Probability ManagementProbability Management
Probability ManagementSchalk Cronjé
 
Seeking Enligtenment - A journey of purpose rather than instruction
Seeking Enligtenment  - A journey of purpose rather than instructionSeeking Enligtenment  - A journey of purpose rather than instruction
Seeking Enligtenment - A journey of purpose rather than instructionSchalk Cronjé
 
Seeking Enligtenment - A journey of purpose rather tan instruction
Seeking Enligtenment - A journey of purpose rather tan instructionSeeking Enligtenment - A journey of purpose rather tan instruction
Seeking Enligtenment - A journey of purpose rather tan instructionSchalk Cronjé
 
Beyond Estimates - Probability Management
Beyond Estimates - Probability ManagementBeyond Estimates - Probability Management
Beyond Estimates - Probability ManagementSchalk Cronjé
 
Documentation An Engineering Problem Unsolved
Documentation  An Engineering Problem UnsolvedDocumentation  An Engineering Problem Unsolved
Documentation An Engineering Problem UnsolvedSchalk Cronjé
 
Death of Agile : Welcome to Value-focused Testing
Death of Agile : Welcome to Value-focused TestingDeath of Agile : Welcome to Value-focused Testing
Death of Agile : Welcome to Value-focused TestingSchalk Cronjé
 
Tree of Knowledge - About Philosophy, Unity & Testing
Tree of Knowledge - About Philosophy, Unity & TestingTree of Knowledge - About Philosophy, Unity & Testing
Tree of Knowledge - About Philosophy, Unity & TestingSchalk Cronjé
 
Beyond estimates - Overview at Agile:MK
Beyond estimates - Overview at Agile:MKBeyond estimates - Overview at Agile:MK
Beyond estimates - Overview at Agile:MKSchalk Cronjé
 
Groovy VFS (with 1.0 news)
Groovy VFS (with 1.0 news)Groovy VFS (with 1.0 news)
Groovy VFS (with 1.0 news)Schalk Cronjé
 
Beyond estimates - Reflection on the state of Agile Forecasting
Beyond estimates - Reflection on the state of Agile ForecastingBeyond estimates - Reflection on the state of Agile Forecasting
Beyond estimates - Reflection on the state of Agile ForecastingSchalk Cronjé
 
Seeking enligtenment - A journey of "Why?" rather than "How?"
Seeking enligtenment - A journey of "Why?" rather than "How?"Seeking enligtenment - A journey of "Why?" rather than "How?"
Seeking enligtenment - A journey of "Why?" rather than "How?"Schalk Cronjé
 
RfC2822 for Mere Mortals
RfC2822 for Mere MortalsRfC2822 for Mere Mortals
RfC2822 for Mere MortalsSchalk Cronjé
 
Prosperity-focused Agile Technology Leadership
Prosperity-focused Agile Technology LeadershipProsperity-focused Agile Technology Leadership
Prosperity-focused Agile Technology LeadershipSchalk Cronjé
 

More from Schalk Cronjé (19)

DocuOps & Asciidoctor in a JVM World
DocuOps & Asciidoctor in a JVM WorldDocuOps & Asciidoctor in a JVM World
DocuOps & Asciidoctor in a JVM World
 
DocuOps & Asciidoctor
DocuOps & AsciidoctorDocuOps & Asciidoctor
DocuOps & Asciidoctor
 
What's new in Asciidoctor
What's new in AsciidoctorWhat's new in Asciidoctor
What's new in Asciidoctor
 
Probability Management
Probability ManagementProbability Management
Probability Management
 
Seeking Enligtenment - A journey of purpose rather than instruction
Seeking Enligtenment  - A journey of purpose rather than instructionSeeking Enligtenment  - A journey of purpose rather than instruction
Seeking Enligtenment - A journey of purpose rather than instruction
 
Seeking Enligtenment - A journey of purpose rather tan instruction
Seeking Enligtenment - A journey of purpose rather tan instructionSeeking Enligtenment - A journey of purpose rather tan instruction
Seeking Enligtenment - A journey of purpose rather tan instruction
 
Beyond Estimates - Probability Management
Beyond Estimates - Probability ManagementBeyond Estimates - Probability Management
Beyond Estimates - Probability Management
 
Documentation An Engineering Problem Unsolved
Documentation  An Engineering Problem UnsolvedDocumentation  An Engineering Problem Unsolved
Documentation An Engineering Problem Unsolved
 
Death of Agile : Welcome to Value-focused Testing
Death of Agile : Welcome to Value-focused TestingDeath of Agile : Welcome to Value-focused Testing
Death of Agile : Welcome to Value-focused Testing
 
Asciidoctor in 15min
Asciidoctor in 15minAsciidoctor in 15min
Asciidoctor in 15min
 
Tree of Knowledge - About Philosophy, Unity & Testing
Tree of Knowledge - About Philosophy, Unity & TestingTree of Knowledge - About Philosophy, Unity & Testing
Tree of Knowledge - About Philosophy, Unity & Testing
 
Beyond estimates - Overview at Agile:MK
Beyond estimates - Overview at Agile:MKBeyond estimates - Overview at Agile:MK
Beyond estimates - Overview at Agile:MK
 
Groovy VFS (with 1.0 news)
Groovy VFS (with 1.0 news)Groovy VFS (with 1.0 news)
Groovy VFS (with 1.0 news)
 
Beyond estimates - Reflection on the state of Agile Forecasting
Beyond estimates - Reflection on the state of Agile ForecastingBeyond estimates - Reflection on the state of Agile Forecasting
Beyond estimates - Reflection on the state of Agile Forecasting
 
Seeking enligtenment - A journey of "Why?" rather than "How?"
Seeking enligtenment - A journey of "Why?" rather than "How?"Seeking enligtenment - A journey of "Why?" rather than "How?"
Seeking enligtenment - A journey of "Why?" rather than "How?"
 
RfC2822 for Mere Mortals
RfC2822 for Mere MortalsRfC2822 for Mere Mortals
RfC2822 for Mere Mortals
 
Groovy VFS
Groovy VFSGroovy VFS
Groovy VFS
 
Prosperity-focused Agile Technology Leadership
Prosperity-focused Agile Technology LeadershipProsperity-focused Agile Technology Leadership
Prosperity-focused Agile Technology Leadership
 
Real World TDD
Real World TDDReal World TDD
Real World TDD
 

Recently uploaded

(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
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-...Steffen Staab
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
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 ApplicationsAlberto González Trastoy
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 

Recently uploaded (20)

(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
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-...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
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
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

Gradle in 45min

  • 2. ABOUT ME Email: Twitter / Ello : @ysb33r ysb33r@gmail.com Gradle plugins authored/contributed to: VFS, Asciidoctor, JRuby family (base, jar, war etc.), GnuMake, Doxygen
  • 3. GET YOUR DAILY GRADLE DOSE @DailyGradle #gradleTip
  • 4. GRADLE A next generation build-and-deploy pipeline tool
  • 5. MOST TRIVIAL JAVA PROJECT apply plugin: 'java' Will look for sources under src/main/java
  • 6. JAVA PROJECT repositories { jcenter() } apply plugin : 'java' dependencies { testCompile 'junit:junit:4.1' }
  • 7. GRADLE DEPENDENCY MANAGEMENT Easy to use Flexible to configure for exceptions Uses dependencies closure First word on line is usually name of a configuration. Configurations are usually supplied by plugins. Dependencies are downloaded from repositories Maven coordinates are used as format
  • 8. GRADLE REPOSITORIES Specified within a repositories closure Processed in listed order to look for dependencies jcenter() preferred open-source repo. mavenLocal(), mavenCentral(), maven {} Ivy repositories via ivy {} Flat-directory repositories via flatDir
  • 9. GRADLE REPOSITORIES repositories { jcenter() mavenCentral() maven { url "https://plugins.gradle.org/m2/" } } repositories { ivy { url 'file://path/to/repo' layout 'pattern', { artifact '[module]/[revision]/[artifact](.[ext])' ivy '[module]/[revision]/ivy.xml' } } }
  • 10. GRADLE DSL Underlying language is Groovy You don’t need to be a Groovy expert to be a Gradle power user Groovy doesn’t need ; in most cases Groovy does more with less punctuation, making it an ideal choice for a DSL In most cases lines that do not end on an operator is considered a completed statement.
  • 11. GROOVY VS JAVA In Groovy: All class members are public by default No need to create getters/setters for public fields Both static & dynamic typing supported def means Object
  • 12. CALLING METHODS class Foo { void bar( def a,def b ) {} } def foo = new Foo() foo.bar( '123',456 ) foo.bar '123', 456 foo.with { bar '123', 456 }
  • 13. CALLING METHODS WITH CLOSURES class Foo { void bar( def a,Closure b ) {} } def foo = new Foo() foo.bar( '123',{ println it } ) foo.bar ('123') { println it } foo.bar '123', { println it }
  • 14. MAPS IN GROOVY Hashmaps in Groovy are simple to use def myMap = [ plugin : 'java' ] Maps are easy to pass inline to functions project.apply( plugin : 'java' ) Which in Gradle can become apply plugin : 'java'
  • 15. LISTS IN GROOVY Lists in Groovy are simple too def myList = [ 'clone', ''http://github.com/ysb33r/GradleLectures' ] This makes it possible for Gradle to do args 'clone', 'http://github.com/ysb33r/GradleLectures'
  • 16. CLOSURE DELEGATION IN GROOVY When a symbol cannot be resolved within a closure, Groovy will look elsewhere In Groovy speak this is called a Delegate. This can be programmatically controlled via the Closure.delegate property.
  • 17. CLOSURE DELEGATION IN GROOVY class Foo { def target } class Bar { Foo foo = new Foo() void doSomething( Closure c ) { c.delegate = foo c() } } Bar bar = new Bar() bar.doSomething { target = 10 }
  • 18. MORE CLOSURE MAGIC If a Groovy class has a method 'call(Closure)`, the object can be passed a closure directly. class Foo { def call( Closure c) { /* ... */ } } Foo foo = new Foo() foo { println 'Hello, world' } // This avoids ugly syntax foo.call({ println 'Hello, world' })
  • 19. CLOSURE DELEGATION IN GRADLE In most cases the delegation will be entity the closure is passed to. Will also look at the Project and ext objects. The Closure.delegate property allows plugin writers ability to create beautiful DSLs task runSomething(type : Exec ) { cmdline 'git' } is roughly the equivalent of ExecTask runSomething = new ExecTask() runSomething.cmdline( 'git' )
  • 20. GRADLE TASKS Can be based upon a task type task runSomething ( type : Exec ) { command 'git' args 'clone', 'https://bitbucket.com/ysb33r/GradleWorkshop' } Can be free-form task hellowWorld << { println 'Hello, world' }
  • 21. GRADLE TASKS : CONFIGURATION VS ACTION Use of << {} adds action to be executed Tasks supplied by plugin will have default actions Use of {} configures a task
  • 22. BUILDSCRIPT The buildscript closure is special It tells Gradle what to load into the classpath before evaluating the script itself. It also tells it where to look for those dependencies. Even though Gradle 2.1 has added a new way of adding external plugins, buildscript are much more flexible.
  • 23. EXTENSIONS Extensions are global configuration blocks added by plugins. Example: The jruby-gradle-base plugin will add a jruby block. apply plugin: 'com.github.jruby-gradle.base' jruby { defaultVersion = '1.7.11' }
  • 24. GRADLE COMMAND-LINE gradle -v gradle -h gradle tasks gradle tasks --info
  • 25. GRADLE WRAPPER Use wrapper where possible: Eliminates need to install Gradle in order to build project Leads to more reproducible builds gradle wrapper --wrapper-version 2.12 ./gradlew tasks
  • 26. EXECUTING TASKS ./gradlew <taskName1> <taskName2> ... ./gradlew build
  • 27. DEPENDENCIES Examine dependencies involved with various configurations ./gradlew dependencies
  • 28. SUPPORT FOR OTHER JVM LANGUAGES
  • 29. GROOVY PROJECT repositories { jcenter() } apply plugin : 'groovy' dependencies { compile 'org.codehaus.groovy:groovy-all:2.4.3' testCompile ('org.spockframework:spock-core:1.0-groovy-2.4') { exclude module : 'groovy-all' } }
  • 30. SCALA PROJECT repositories { jcenter() } apply plugin : 'scala' dependencies { compile 'org.scala-lang:scala-library:2.11.8' }
  • 31. BUILDING KOTLIN plugins { id "com.zoltu.kotlin" version "1.0.1" } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:1.0.1-1" }
  • 32. RUNNING JRUBY plugins { id 'com.github.jruby-gradle.base' version '1.2.1' } import com.github.jrubygradle.JRubyExec dependencies { jrubyExec "rubygems:colorize:0.7.7" } task printSomePrettyOutputPlease(type: JRubyExec) { description "Execute our nice local print-script.rb" script "${projectDir}/print-script.rb" } (Example from JRuby-Gradle project)
  • 33. OTHER LANGUAGES C++ / C / ASM / Resources (built-in) Clojure (plugin) Frege (plugin) Golang (plugin) Gosu (plugin) Mirah (plugin in progress)
  • 34. SUPPORT FOR OTHER BUILDSYSTEMS ANT (built-in) GNU Make MSBuild / xBuild Grunt, Gulp Anything else cra able via Exec or JavaExec task
  • 35. BUILDING DOCUMENTATION Javadoc, Groovydoc, Scaladoc (built-in) Doxygen (C, C++) (plugin) Markdown (plugin) Asciidoctor (plugin)
  • 36. BUILDING WITH ASCIIDOCTOR plugins { id 'org.asciidoctor.convert' version '1.5.2' }
  • 37. BUILDING WITH ASCIIDOCTOR repositories { jcenter() } asciidoctor { sources { include 'example.adoc' } backends 'html5' }
  • 38. PUBLISHING Built-in to Maven, Ivy Metadata publishing for native projects still lacking Various plugins for AWS and other cloud storage Plain old copies to FTP, SFTP etc.
  • 39. MORE SUPPORT… Official buildsystem for Android Docker Hadoop
  • 40. TOUR DE FORCE Build a distributable application packaged as as ZIP Runnable via shell script or batch file Contains classes written Java, Groovy & Kotlin source Test source code with Spock Framework
  • 41. TOUR DE FORCE plugins { id 'java' id 'groovy' id 'com.zoltu.kotlin' version '1.0.1' id 'application' } repositories { jcenter() } dependencies { compile 'org.codehaus.groovy:groovy-all:2.4.3' compile 'org.jetbrains.kotlin:kotlin-stdlib:1.0.1-1' testCompile 'org.spockframework:spock-core:1.0-groovy-2.4' } version = '1.0' mainClassName = "gradle.workshop.HelloJava" compileGroovy.dependsOn compileKotlin
  • 42. ENDGAME Gradle is breaking new ground Ever improving native support Continuous performance improvements Go find some more plugins at https://plugins.gradle.org
  • 43. ABOUT THIS PRESENTATION Written in Asciidoctor Styled by asciidoctor-revealjs extension Built using: Gradle gradle-asciidoctor-plugin gradle-vfs-plugin Code snippets tested as part of build Source code: https://github.com/ysb33r/GradleLectures/tree/MkJugMar201
  • 44. THANK YOU Email: Twitter / Ello : @ysb33r #idiomaticgradle ysb33r@gmail.com https://leanpub.com/idiomaticgradle
  • 46. ANT TO GRADLE Reflect Ant Build into Gradle ant.importBuild('build.xml')
  • 47. MAVEN TO GRADLE Go to directory where pom.xml is and type gradle init --type pom
  • 49. PUBLISHING VIA VFS plugins { id "org.ysb33r.vfs" version "1.0-beta3" } task publishToWebserver << { vfs { cp "${buildDir}/website", "ftp://${username}:${password}@int.someserver.com/var/www", recursive : true, overwrite : true } }