SlideShare uma empresa Scribd logo
1 de 57
1




                   In The Brain 2009

                        Gradle


Hans Dockter

Gradle Project Lead

mail@dockter.biz
2



About Me



Founder and Project Lead of Gradle

CEO of Gradle Inc.

Trainer for Skills Matter (TTD, Patterns, DDD)

In the old days: Committer to JBoss (Founder of JBoss-IDE)
3




Gradle Overview 1

 A flexible general purpose build tool

   Offers dependency based programming with a rich API

 Build-by-convention plugins on top

 Powerful multi-project support

 Powerful dependency management based on Apache Ivy

 Deep Integration with Ant
4




Gradle Overview 2
 Build Scripts are written in Groovy
    We get our general purpose elements from a full blown OO language

    The perfect base to provide a mix of:
       Small frameworks, toolsets and dependency based programming

    Rich interaction with Java

    Gradle is NOT a framework

 Gradle is mostly written in Java with a Groovy DSL layer on top
 Offers good documentation (150+ Pages user’s guide)
 Commiter -> Steve Appling, Hans Dockter, Tom Eyckmans, Adam
 Murdoch, Russel Winder
5




Dependency Based Programming
 task hello << {
     println 'Hello world!'
 }

 task intro(dependsOn: hello) << {
     println "I'm Gradle"
 }

 4.times { counter ->
     task "task_$counter" << {
         println "I'm task $counter"
     }
 }
 > gradle hello task1
 Hello world!
 I’m task 1
6




Rich API

 task hello
 println hello.name
 hello.dependsOn distZip
 hello << { println ‘Hello’ }

 task distZip(type: Zip)
 distZip.fileSet(dir: ‘somePath’)
 distZip.baseName = hello.name
7




Very Rich API: Test Task

 Register listeners for test execution (this works even in forked mode)

   Get informed about a started test execution

   Get informed about a failing or succeeding test

 Provides an API to ask for execution results.

 Part of Gradle 0.8
8




One way configuration Ant


 <target name="test" depends="compile-test">
     <junit>
       <classpath refid="classpath.test" />
       <formatter type="brief" usefile="false" />
       <test name="${test.suite}"/>
     </junit>
 </target>
9




One way configuration Maven

 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.4.2</version>
    <configuration>
       <includes>
           <include>Sample.java</include>
       </includes>
    </configuration>
 </plugin>
10




Java Plugin
usePlugin(‘java’)
10




Java Plugin
usePlugin(‘java’)
repositories {
  mavenCentral()
}

dependencies {
  compile "commons-lang:commons-lang:3.1", "org.hibernate:hibernate:3.2"
  runtime “mysql:mysql-connector-java:5.1.6”
  testCompile "junit:junit:4.4"
}
10




Java Plugin
usePlugin(‘java’)
repositories {
  mavenCentral()
}

dependencies {
  compile "commons-lang:commons-lang:3.1", "org.hibernate:hibernate:3.2"
  runtime “mysql:mysql-connector-java:5.1.6”
  testCompile "junit:junit:4.4"
}

test {
  exclude '**/Abstract*'
}

task preCompile << { // do something }
compile.dependsOn preCompile

task myDocs(type: Zip) {
  fileset(dir: "path/docs")
}
11




Custom Plugins

public class CustomPlugin implements Plugin {
  public void use(final Project project, ProjectPluginsContainer plugins) {
      project.myProperty = ‘myValue’
      plugins.withType(JavaPlugin).allPlugins {
            project.getTasks().add(‘someName’, SomeType.class)
      }
      plugins.withType(WarPlugin.class).allPlugins {
            // do something with the project
      }
  }
12




Deep API
 tasks.whenTaskAdded { task ->
     task.description = ‘This is a new task’
 }

 tasks.allTasks { task ->
     task.description = ‘I am new or old’
 }

 tasks.withType(Zip).whenTaskAdded { task ->
     task.fileSet(dir: ‘someDir’)
 }

 liveLibs = tasks.withType(Jar)
 task someJar(type: Jar)
 println liveLibs.all // prints [‘someJar’]
13




Rules
 tasks.addRule("Pattern: ping<ID>") { String taskName ->
     if (taskName.startsWith("ping")) {
         task(taskName) << { // add task
             println "Pinging: " + (taskName - 'ping')
         }
     }
 }
 task groupPing {
     dependsOn pingServer1, pingServer2
 }

 > gradle pingServer545
 Server545

 > gradle groupPing
 Server1
 Server2
14




Dependency Management 1
usePlugin(‘java’)
...
configurations {
    allJar.extends runtime
}

dependencies {
    compile "commons-lang:commons-lang:3.1", "org.hibernate:hibernate:3.2"
    runtime “mysql:mysql-connector-java:5.1.6”
    testCompile "junit:junit:4.4"
    allJar "commons-io:commons-io:1.4"
}
...
task jarAll(type: Jar) {
    merge(dependencies.allJar.resolve())
}
15




Dependency Management 2
usePlugin(‘java’)
...

dependencies {
    compile "commons-lang:commons-lang:3.1", "org.hibernate:hibernate:3.2"
    runtime “mysql:mysql-connector-java:5.1.6”
    testCompile "junit:junit:4.4"
}
...
task showDeps << {
    println(configurations.runtime.files { dep -> dep.group == ‘myGroup’ })
}
16




Dependency Management 3

 Excludes per configuration or dependency

 You can define rules for configuration and dependencies (as for tasks)

 Very flexible repository handling

 Retrieve and deploy from/to Maven repositories

 Dependencies can have dynamic properties

 And much more
17




Using Ant Tasks
ant {
   taskdef name: "groovyc", classname: "org.groovy.ant.Groovyc"
   groovyc srcdir: "src", destdir: "${webinf}/classes", {
      classpath {

         fileset dir: "lib" {

            include name: "*.jar"
          }

         pathelement path: "classes"
      }
      javac source: "1.5", target: "1.5", debug: "on"
   }
}
18




Deep Integration with Ant Builds
<project>
    <target name="hello" depends="intro">
        <echo>Hello, from Ant</echo>
    </target>
</project>

ant.importBuild 'build.xml'

hello.doFirst { println 'Here comes Ant' }
task intro << { println 'Hello, from Gradle'}




> gradle hello
Hello, from Gradle...Here comes Ant...[ant:echo] Hello, from Ant
19




Smart and Configurable
      Execution
20




Deep API
usePlugin(‘java’)
...
compile.doFirst { compileTask ->
    println build.taskGraph.allTasks
    if (build.taskGraph.hasTask(‘codeGeneration’)) {
       compileTask.exclude ‘com.mycomp.somePackage’
    }
}

build.taskGraph.beforeTask { task ->
  println “I am executing now $task.name”
}

build.taskGraph.afterTask { task, exception ->
  if (task instanceof Jetty && exception != null) {
     // do something
  }
}
21




Smart Task Exclusion

     A
                                              C

                         B




         E                          D



         In Gradle 0.7 you can execute: gradle A B!
22




Smart Merging

         test                                 resources


                        compile


                                      clean




> gradle clean compile test

> gradle clean compile; gradle test
23




Smart Skipping


usePlugin(‘java’)
...
task instrument(dependsOn: compile) {
    onlyIf {
       timestampChanged classesDir // or contentsChanged classesDir
    }
    // do something
}
24




Multi-Project Builds


 Arbitrary Multiproject Layout

 Configuration Injection

 Separate Config/Execution Hierarchy

 Partial builds
25




Configuration Injection
   ultimateApp
      api
      webservice
      shared


subprojects {
  usePlugin(‘java’)
  dependencies {
     compile "commons-lang:commons-lang:3.1"
     testCompile "junit:junit:4.4"
  }
  test {
     exclude '**/Abstract*'
   }
}
26




Separation of Config/Exec
   ultimateApp
       api
       webservice
       shared
dependsOnChildren()
subprojects {
  usePlugin(‘java’)
  dependencies {
    compile "commons-lang:commons-lang:3.1"
    testCompile "junit:junit:4.4"
  }
}

task dist(type: Zip) << {
  subprojects.each { subproject ->
    files(subproject.jar.archivePath)
  }
}
27




Dependencies and Partial Builds
   ultimateApp
       api
       webservice
       shared

dependsOn webservice
dependencies {
  compile "commons-lang:commons-lang:3.1", project(‘:shared’)
}
28




Maven
29




Convention instead of Configuration
30




Frameworkitis ...
... is the disease that a framework wants to do too much for you or it does it
in a way that you don’t want but you can’t change it. It’s fun to get all this
functionality for free, but it hurts when the free functionality gets in the way.
But you are now tied into the framework. To get the desired behavior you
start to fight against the framework. And at this point you often start to lose,
because it’s difficult to bend the framework in a direction it didn’t anticipate.
Toolkits do not attempt to take control for you and they therefore do not
suffer from frameworkitis.
(Erich Gamma)
31




Solution
Because the bigger the framework becomes, the greater the chances that it
will want to do too much, the bigger the learning curves become, and the
more difficult it becomes to maintain it. If you really want to take the risk of
doing frameworks, you want to have small and focused frameworks that
you can also probably make optional. If you really want to, you can use the
framework, but you can also use the toolkit. That’s a good position that
avoids this frameworkitis problem, where you get really frustrated because
you have to use the framework. Ideally I’d like to have a toolbox of smaller
frameworks where I can pick and choose, so that I can pay the framework
costs as I go.(Erich Gamma)
32




Build Language
    instead of
Build Framework
33




Organizing Build Logic

 No unnecessary indirections

 If build specific:

    Within the script

    Build Sources

 Otherwise: Jar
34




Gradle Wrapper

 Use Gradle without having Gradle installed

 Useful for CI and open source projects
35




Production Ready?


 YES! (If you don’t need a missing feature).

 There are already large enterprise builds migrating from Ant and Maven to
 Gradle

 Expect 1.0 in autumn

 Roadmap: see http://www.gradle.org/roadmap
36




Questions
37




The old bulls ...
38




          ANT

Ant’s domain model in five
         words?
39




                   Ant

Properties                            Resources


 Targets                                 Tasks




 Flexible Toolset via dependency based programming
40




Ant, XML and DRY
41




Build By Convention




             Multi-Project Builds
42




Live Demo - Hello World
43




                     Maven


       Build-By-Convention
            Framework                Plugins

Abstractions for Software Projects


                   Dependency Management
44




Live Demo - Java
45




   There
    are
     no
simple builds
46




Project Automation


 A build can do far more than just building the jar

 Often repetitive, time consuming, boring stuff is still done manually
    Many of those tasks are very company specific

    Maven & Ant are often not well suited for this
47




The Gradle Build

 Gradle is build with Gradle

 Automatic release management

 Automatic user’s guide generation

 Automatic distribution

 Behavior depends on task execution graph
48




Release Management

 The version number is automatically calculated

 The distribution is build and uploaded to codehaus

 For trunk releases, a new svn branch is created.

 A tag is created.

 A new version properties file is commited.

 The download links on the website are updated
49




User’s Guide

 The user’s guide is written in DocBook and generated by our build

 The source code examples are mostly real tests and are automatically
 included

 The expected output of those tests is automatically included.

 The tests are run

 The current version is added to the title
50




Uploading & Execution Graph



 Based on the task graph we set:

   Upload Destination

   Version Number
51




Why Groovy scripts?
51




                 Why Groovy scripts?
[‘Maven’, ‘Ant’, ‘Gradle’].findAll { it.indexOf(‘G’) > -1 }
51




                 Why Groovy scripts?
[‘Maven’, ‘Ant’, ‘Gradle’].findAll { it.indexOf(‘G’) > -1 }




      Why not JRuby or Jython scripts?
51




                 Why Groovy scripts?
[‘Maven’, ‘Ant’, ‘Gradle’].findAll { it.indexOf(‘G’) > -1 }




      Why not JRuby or Jython scripts?

                   Why a Java core?
52




Java Plugin
usePlugin(‘java’)
manifest.mainAttributes([
   'Implementation-Title': 'Gradle',
   'Implementation-Version': '0.1'
])
dependencies {
   compile "commons-lang:commons-lang:3.1"
   runtime “mysql:mysql-connector-java:5.1.6”
   testCompile "junit:junit:4.4"
}
sourceCompatibility = 1.5
targetCompatibility = 1.5
test {
   exclude '**/Abstract*'
}

task(type: Zip) {
   zip() {
      files(dependencies.runtime.resolve() // add dependencies to zip
      fileset(dir: "path/distributionFiles")
   }
}

Mais conteúdo relacionado

Mais procurados

[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
 
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
 
Idiomatic gradle plugin writing
Idiomatic gradle plugin writingIdiomatic gradle plugin writing
Idiomatic gradle plugin writingSchalk Cronjé
 
Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolvedBhagwat Kumar
 
Managing user's data with Spring Session
Managing user's data with Spring SessionManaging user's data with Spring Session
Managing user's data with Spring SessionDavid Gómez García
 
Gradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionGradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionSchalk Cronjé
 
10 Cool Facts about Gradle
10 Cool Facts about Gradle10 Cool Facts about Gradle
10 Cool Facts about GradleEvgeny Goldin
 
Using the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM DevelopmentUsing the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM DevelopmentSchalk Cronjé
 
Groovy, Transforming Language
Groovy, Transforming LanguageGroovy, Transforming Language
Groovy, Transforming LanguageUehara Junji
 
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
 
Basic Gradle Plugin Writing
Basic Gradle Plugin WritingBasic Gradle Plugin Writing
Basic Gradle Plugin WritingSchalk Cronjé
 
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
 
Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)Joachim Baumann
 
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?Srijan Technologies
 
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
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingSchalk Cronjé
 

Mais procurados (20)

[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...
 
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
 
Idiomatic gradle plugin writing
Idiomatic gradle plugin writingIdiomatic gradle plugin writing
Idiomatic gradle plugin writing
 
Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolved
 
Managing user's data with Spring Session
Managing user's data with Spring SessionManaging user's data with Spring Session
Managing user's data with Spring Session
 
Gradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionGradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 version
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
10 Cool Facts about Gradle
10 Cool Facts about Gradle10 Cool Facts about Gradle
10 Cool Facts about Gradle
 
Using the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM DevelopmentUsing the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM Development
 
GradleFX
GradleFXGradleFX
GradleFX
 
Groovy, Transforming Language
Groovy, Transforming LanguageGroovy, Transforming Language
Groovy, Transforming Language
 
Gradle 3.0: Unleash the Daemon!
Gradle 3.0: Unleash the Daemon!Gradle 3.0: Unleash the Daemon!
Gradle 3.0: Unleash the Daemon!
 
Basic Gradle Plugin Writing
Basic Gradle Plugin WritingBasic Gradle Plugin Writing
Basic Gradle Plugin Writing
 
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
 
Hands on the Gradle
Hands on the GradleHands on the Gradle
Hands on the Gradle
 
Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)
 
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
 
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!
 
Angular beans
Angular beansAngular beans
Angular beans
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
 

Destaque

Five Steps to Kanban
Five Steps to KanbanFive Steps to Kanban
Five Steps to KanbanSkills Matter
 
Using Language Oriented Programming to Execute Computations on the GPU
Using Language Oriented Programming to Execute Computations on the GPUUsing Language Oriented Programming to Execute Computations on the GPU
Using Language Oriented Programming to Execute Computations on the GPUSkills Matter
 
UK G-Cloud: The First Instantiation of True Cloud?
UK G-Cloud: The First Instantiation of True Cloud?UK G-Cloud: The First Instantiation of True Cloud?
UK G-Cloud: The First Instantiation of True Cloud?Skills Matter
 
Cqrs Ldnug 200100304
Cqrs   Ldnug 200100304Cqrs   Ldnug 200100304
Cqrs Ldnug 200100304Skills Matter
 
Narrative Acceptance Tests River Glide Antony Marcano
Narrative Acceptance Tests River Glide Antony MarcanoNarrative Acceptance Tests River Glide Antony Marcano
Narrative Acceptance Tests River Glide Antony MarcanoSkills Matter
 
5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard Lawrence5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard LawrenceSkills Matter
 

Destaque (8)

Five Steps to Kanban
Five Steps to KanbanFive Steps to Kanban
Five Steps to Kanban
 
Using Language Oriented Programming to Execute Computations on the GPU
Using Language Oriented Programming to Execute Computations on the GPUUsing Language Oriented Programming to Execute Computations on the GPU
Using Language Oriented Programming to Execute Computations on the GPU
 
Sug Jan 19
Sug Jan 19Sug Jan 19
Sug Jan 19
 
UK G-Cloud: The First Instantiation of True Cloud?
UK G-Cloud: The First Instantiation of True Cloud?UK G-Cloud: The First Instantiation of True Cloud?
UK G-Cloud: The First Instantiation of True Cloud?
 
Cqrs Ldnug 200100304
Cqrs   Ldnug 200100304Cqrs   Ldnug 200100304
Cqrs Ldnug 200100304
 
Narrative Acceptance Tests River Glide Antony Marcano
Narrative Acceptance Tests River Glide Antony MarcanoNarrative Acceptance Tests River Glide Antony Marcano
Narrative Acceptance Tests River Glide Antony Marcano
 
Oc Cloud Obscurity
Oc Cloud ObscurityOc Cloud Obscurity
Oc Cloud Obscurity
 
5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard Lawrence5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard Lawrence
 

Semelhante a In the Brain of Hans Dockter: Gradle

Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01Tino Isnich
 
Improving your Gradle builds
Improving your Gradle buildsImproving your Gradle builds
Improving your Gradle buildsPeter Ledbrook
 
Gradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting forGradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting forCorneil du Plessis
 
Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)Jared Burrows
 
Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!Roberto Franchini
 
Testing your application on Google App Engine
Testing your application on Google App EngineTesting your application on Google App Engine
Testing your application on Google App EngineInphina Technologies
 
Testing Your Application On Google App Engine
Testing Your Application On Google App EngineTesting Your Application On Google App Engine
Testing Your Application On Google App EngineIndicThreads
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleThierry Wasylczenko
 
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
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGuillaume Laforge
 
Automated integration testing of distributed systems with Docker Compose and ...
Automated integration testing of distributed systems with Docker Compose and ...Automated integration testing of distributed systems with Docker Compose and ...
Automated integration testing of distributed systems with Docker Compose and ...Boris Kravtsov
 
Dropwizard and Friends
Dropwizard and FriendsDropwizard and Friends
Dropwizard and FriendsYun Zhi Lin
 
Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018Petr Zapletal
 

Semelhante a In the Brain of Hans Dockter: Gradle (20)

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
 
Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01
 
Gradle
GradleGradle
Gradle
 
Improving your Gradle builds
Improving your Gradle buildsImproving your Gradle builds
Improving your Gradle builds
 
Gradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting forGradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting for
 
Why gradle
Why gradle Why gradle
Why gradle
 
Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)
 
Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!
 
Js tacktalk team dev js testing performance
Js tacktalk team dev js testing performanceJs tacktalk team dev js testing performance
Js tacktalk team dev js testing performance
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
Testing your application on Google App Engine
Testing your application on Google App EngineTesting your application on Google App Engine
Testing your application on Google App Engine
 
Testing Your Application On Google App Engine
Testing Your Application On Google App EngineTesting Your Application On Google App Engine
Testing Your Application On Google App Engine
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec 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
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
 
Automated integration testing of distributed systems with Docker Compose and ...
Automated integration testing of distributed systems with Docker Compose and ...Automated integration testing of distributed systems with Docker Compose and ...
Automated integration testing of distributed systems with Docker Compose and ...
 
Enter the gradle
Enter the gradleEnter the gradle
Enter the gradle
 
Dropwizard and Friends
Dropwizard and FriendsDropwizard and Friends
Dropwizard and Friends
 
Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018
 

Mais de Skills Matter

Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applicationsSkills Matter
 
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmScala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmSkills Matter
 
Oscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheimOscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheimSkills Matter
 
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Skills Matter
 
Cukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberlCukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberlSkills Matter
 
Cukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.jsCukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.jsSkills Matter
 
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...Skills Matter
 
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...Skills Matter
 
Progressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source worldProgressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source worldSkills Matter
 
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...Skills Matter
 
Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#Skills Matter
 
A poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testingA poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testingSkills Matter
 
Russ miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-diveRuss miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-diveSkills Matter
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSkills Matter
 
I went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_tI went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_tSkills Matter
 

Mais de Skills Matter (20)

Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applications
 
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmScala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
 
Oscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheimOscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheim
 
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
 
Cukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberlCukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberl
 
Cukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.jsCukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.js
 
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
 
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
 
Progressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source worldProgressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source world
 
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
 
Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#
 
A poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testingA poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testing
 
Russ miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-diveRuss miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-dive
 
Serendipity-neo4j
Serendipity-neo4jSerendipity-neo4j
Serendipity-neo4j
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
 
Plug 20110217
Plug   20110217Plug   20110217
Plug 20110217
 
Lug presentation
Lug presentationLug presentation
Lug presentation
 
I went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_tI went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_t
 
Plug saiku
Plug   saikuPlug   saiku
Plug saiku
 
Huguk lily
Huguk lilyHuguk lily
Huguk lily
 

Último

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 

Último (20)

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 

In the Brain of Hans Dockter: Gradle

  • 1. 1 In The Brain 2009 Gradle Hans Dockter Gradle Project Lead mail@dockter.biz
  • 2. 2 About Me Founder and Project Lead of Gradle CEO of Gradle Inc. Trainer for Skills Matter (TTD, Patterns, DDD) In the old days: Committer to JBoss (Founder of JBoss-IDE)
  • 3. 3 Gradle Overview 1 A flexible general purpose build tool Offers dependency based programming with a rich API Build-by-convention plugins on top Powerful multi-project support Powerful dependency management based on Apache Ivy Deep Integration with Ant
  • 4. 4 Gradle Overview 2 Build Scripts are written in Groovy We get our general purpose elements from a full blown OO language The perfect base to provide a mix of: Small frameworks, toolsets and dependency based programming Rich interaction with Java Gradle is NOT a framework Gradle is mostly written in Java with a Groovy DSL layer on top Offers good documentation (150+ Pages user’s guide) Commiter -> Steve Appling, Hans Dockter, Tom Eyckmans, Adam Murdoch, Russel Winder
  • 5. 5 Dependency Based Programming task hello << { println 'Hello world!' } task intro(dependsOn: hello) << { println "I'm Gradle" } 4.times { counter -> task "task_$counter" << { println "I'm task $counter" } } > gradle hello task1 Hello world! I’m task 1
  • 6. 6 Rich API task hello println hello.name hello.dependsOn distZip hello << { println ‘Hello’ } task distZip(type: Zip) distZip.fileSet(dir: ‘somePath’) distZip.baseName = hello.name
  • 7. 7 Very Rich API: Test Task Register listeners for test execution (this works even in forked mode) Get informed about a started test execution Get informed about a failing or succeeding test Provides an API to ask for execution results. Part of Gradle 0.8
  • 8. 8 One way configuration Ant <target name="test" depends="compile-test"> <junit> <classpath refid="classpath.test" /> <formatter type="brief" usefile="false" /> <test name="${test.suite}"/> </junit> </target>
  • 9. 9 One way configuration Maven <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.4.2</version> <configuration> <includes> <include>Sample.java</include> </includes> </configuration> </plugin>
  • 11. 10 Java Plugin usePlugin(‘java’) repositories { mavenCentral() } dependencies { compile "commons-lang:commons-lang:3.1", "org.hibernate:hibernate:3.2" runtime “mysql:mysql-connector-java:5.1.6” testCompile "junit:junit:4.4" }
  • 12. 10 Java Plugin usePlugin(‘java’) repositories { mavenCentral() } dependencies { compile "commons-lang:commons-lang:3.1", "org.hibernate:hibernate:3.2" runtime “mysql:mysql-connector-java:5.1.6” testCompile "junit:junit:4.4" } test { exclude '**/Abstract*' } task preCompile << { // do something } compile.dependsOn preCompile task myDocs(type: Zip) { fileset(dir: "path/docs") }
  • 13. 11 Custom Plugins public class CustomPlugin implements Plugin { public void use(final Project project, ProjectPluginsContainer plugins) { project.myProperty = ‘myValue’ plugins.withType(JavaPlugin).allPlugins { project.getTasks().add(‘someName’, SomeType.class) } plugins.withType(WarPlugin.class).allPlugins { // do something with the project } }
  • 14. 12 Deep API tasks.whenTaskAdded { task -> task.description = ‘This is a new task’ } tasks.allTasks { task -> task.description = ‘I am new or old’ } tasks.withType(Zip).whenTaskAdded { task -> task.fileSet(dir: ‘someDir’) } liveLibs = tasks.withType(Jar) task someJar(type: Jar) println liveLibs.all // prints [‘someJar’]
  • 15. 13 Rules tasks.addRule("Pattern: ping<ID>") { String taskName -> if (taskName.startsWith("ping")) { task(taskName) << { // add task println "Pinging: " + (taskName - 'ping') } } } task groupPing { dependsOn pingServer1, pingServer2 } > gradle pingServer545 Server545 > gradle groupPing Server1 Server2
  • 16. 14 Dependency Management 1 usePlugin(‘java’) ... configurations { allJar.extends runtime } dependencies { compile "commons-lang:commons-lang:3.1", "org.hibernate:hibernate:3.2" runtime “mysql:mysql-connector-java:5.1.6” testCompile "junit:junit:4.4" allJar "commons-io:commons-io:1.4" } ... task jarAll(type: Jar) { merge(dependencies.allJar.resolve()) }
  • 17. 15 Dependency Management 2 usePlugin(‘java’) ... dependencies { compile "commons-lang:commons-lang:3.1", "org.hibernate:hibernate:3.2" runtime “mysql:mysql-connector-java:5.1.6” testCompile "junit:junit:4.4" } ... task showDeps << { println(configurations.runtime.files { dep -> dep.group == ‘myGroup’ }) }
  • 18. 16 Dependency Management 3 Excludes per configuration or dependency You can define rules for configuration and dependencies (as for tasks) Very flexible repository handling Retrieve and deploy from/to Maven repositories Dependencies can have dynamic properties And much more
  • 19. 17 Using Ant Tasks ant { taskdef name: "groovyc", classname: "org.groovy.ant.Groovyc" groovyc srcdir: "src", destdir: "${webinf}/classes", { classpath { fileset dir: "lib" { include name: "*.jar" } pathelement path: "classes" } javac source: "1.5", target: "1.5", debug: "on" } }
  • 20. 18 Deep Integration with Ant Builds <project> <target name="hello" depends="intro"> <echo>Hello, from Ant</echo> </target> </project> ant.importBuild 'build.xml' hello.doFirst { println 'Here comes Ant' } task intro << { println 'Hello, from Gradle'} > gradle hello Hello, from Gradle...Here comes Ant...[ant:echo] Hello, from Ant
  • 22. 20 Deep API usePlugin(‘java’) ... compile.doFirst { compileTask -> println build.taskGraph.allTasks if (build.taskGraph.hasTask(‘codeGeneration’)) { compileTask.exclude ‘com.mycomp.somePackage’ } } build.taskGraph.beforeTask { task -> println “I am executing now $task.name” } build.taskGraph.afterTask { task, exception -> if (task instanceof Jetty && exception != null) { // do something } }
  • 23. 21 Smart Task Exclusion A C B E D In Gradle 0.7 you can execute: gradle A B!
  • 24. 22 Smart Merging test resources compile clean > gradle clean compile test > gradle clean compile; gradle test
  • 25. 23 Smart Skipping usePlugin(‘java’) ... task instrument(dependsOn: compile) { onlyIf { timestampChanged classesDir // or contentsChanged classesDir } // do something }
  • 26. 24 Multi-Project Builds Arbitrary Multiproject Layout Configuration Injection Separate Config/Execution Hierarchy Partial builds
  • 27. 25 Configuration Injection ultimateApp api webservice shared subprojects { usePlugin(‘java’) dependencies { compile "commons-lang:commons-lang:3.1" testCompile "junit:junit:4.4" } test { exclude '**/Abstract*' } }
  • 28. 26 Separation of Config/Exec ultimateApp api webservice shared dependsOnChildren() subprojects { usePlugin(‘java’) dependencies { compile "commons-lang:commons-lang:3.1" testCompile "junit:junit:4.4" } } task dist(type: Zip) << { subprojects.each { subproject -> files(subproject.jar.archivePath) } }
  • 29. 27 Dependencies and Partial Builds ultimateApp api webservice shared dependsOn webservice dependencies { compile "commons-lang:commons-lang:3.1", project(‘:shared’) }
  • 31. 29 Convention instead of Configuration
  • 32. 30 Frameworkitis ... ... is the disease that a framework wants to do too much for you or it does it in a way that you don’t want but you can’t change it. It’s fun to get all this functionality for free, but it hurts when the free functionality gets in the way. But you are now tied into the framework. To get the desired behavior you start to fight against the framework. And at this point you often start to lose, because it’s difficult to bend the framework in a direction it didn’t anticipate. Toolkits do not attempt to take control for you and they therefore do not suffer from frameworkitis. (Erich Gamma)
  • 33. 31 Solution Because the bigger the framework becomes, the greater the chances that it will want to do too much, the bigger the learning curves become, and the more difficult it becomes to maintain it. If you really want to take the risk of doing frameworks, you want to have small and focused frameworks that you can also probably make optional. If you really want to, you can use the framework, but you can also use the toolkit. That’s a good position that avoids this frameworkitis problem, where you get really frustrated because you have to use the framework. Ideally I’d like to have a toolbox of smaller frameworks where I can pick and choose, so that I can pay the framework costs as I go.(Erich Gamma)
  • 34. 32 Build Language instead of Build Framework
  • 35. 33 Organizing Build Logic No unnecessary indirections If build specific: Within the script Build Sources Otherwise: Jar
  • 36. 34 Gradle Wrapper Use Gradle without having Gradle installed Useful for CI and open source projects
  • 37. 35 Production Ready? YES! (If you don’t need a missing feature). There are already large enterprise builds migrating from Ant and Maven to Gradle Expect 1.0 in autumn Roadmap: see http://www.gradle.org/roadmap
  • 40. 38 ANT Ant’s domain model in five words?
  • 41. 39 Ant Properties Resources Targets Tasks Flexible Toolset via dependency based programming
  • 43. 41 Build By Convention Multi-Project Builds
  • 44. 42 Live Demo - Hello World
  • 45. 43 Maven Build-By-Convention Framework Plugins Abstractions for Software Projects Dependency Management
  • 47. 45 There are no simple builds
  • 48. 46 Project Automation A build can do far more than just building the jar Often repetitive, time consuming, boring stuff is still done manually Many of those tasks are very company specific Maven & Ant are often not well suited for this
  • 49. 47 The Gradle Build Gradle is build with Gradle Automatic release management Automatic user’s guide generation Automatic distribution Behavior depends on task execution graph
  • 50. 48 Release Management The version number is automatically calculated The distribution is build and uploaded to codehaus For trunk releases, a new svn branch is created. A tag is created. A new version properties file is commited. The download links on the website are updated
  • 51. 49 User’s Guide The user’s guide is written in DocBook and generated by our build The source code examples are mostly real tests and are automatically included The expected output of those tests is automatically included. The tests are run The current version is added to the title
  • 52. 50 Uploading & Execution Graph Based on the task graph we set: Upload Destination Version Number
  • 54. 51 Why Groovy scripts? [‘Maven’, ‘Ant’, ‘Gradle’].findAll { it.indexOf(‘G’) > -1 }
  • 55. 51 Why Groovy scripts? [‘Maven’, ‘Ant’, ‘Gradle’].findAll { it.indexOf(‘G’) > -1 } Why not JRuby or Jython scripts?
  • 56. 51 Why Groovy scripts? [‘Maven’, ‘Ant’, ‘Gradle’].findAll { it.indexOf(‘G’) > -1 } Why not JRuby or Jython scripts? Why a Java core?
  • 57. 52 Java Plugin usePlugin(‘java’) manifest.mainAttributes([ 'Implementation-Title': 'Gradle', 'Implementation-Version': '0.1' ]) dependencies { compile "commons-lang:commons-lang:3.1" runtime “mysql:mysql-connector-java:5.1.6” testCompile "junit:junit:4.4" } sourceCompatibility = 1.5 targetCompatibility = 1.5 test { exclude '**/Abstract*' } task(type: Zip) { zip() { files(dependencies.runtime.resolve() // add dependencies to zip fileset(dir: "path/distributionFiles") } }