Gradle

A Groovy DSL based declarative general purpose build system with a particular emphasis on JVM languages.

Groovy

A Java-like scripting language for the JVM.

  • Syntactic superset of Java.
  • Use existing JARs.
  • Closures.
  • Builders (special collection syntax).
  • Dynamic typing with optional declarations.
  • Named params.
  • Flexible syntax, great for DSLs.

Gradle Features

  • Configuration injection (very DRY).
  • Dynamic creation and modification of tasks.
  • Supports ant tasks.
  • Task dependencies.
  • Support code (groovy, java).
  • Strict on property names (ext).
  • Nice GUI.
  • Good error reporting (sp. line numbers).
  • Extensive documentation and tutorials.
  • Gobs of examples.
  • Lots o' plugins.

Gradle Architecture

  • Assumes nothing about how projects should work or be structured.
  • Framework is a generic engine for task graphs with configuration.
  • Projects are containers for configuration and tasks.

    Configuration can be used to provide values but also to influence behavior.

  • Project dependencies are expressed by configuration.

Tasks

  • Mixture of Ant's task and target types.
  • Type, Configuration, Dependencies, Actions
  • Can be decorated with actions anywhere.
    • doFirst
    • doLast
  • many types, e.g. Copy, Zip, GradleBuild
  • use files in and out to check staleness.
  • Lifecycle
    • Configured
    • Executed
  • Introduced primarily via plugins.

Projects

  • Containers for tasks and configuration.
  • Dependencies expressed via configuration.
  • Separate files are optional.

Tasks in a blank project

    Help tasks
    ----------
    dependencies - Displays all dependencies declared in root project 'gradle'.
    dependencyInsight - Displays the insight into a specific dependency in root project 'gradle'.
    help - Displays a help message
    projects - Displays the sub-projects of root project 'gradle'.
    properties - Displays the properties of root project 'gradle'.
    tasks - Displays the tasks runnable from root project 'gradle' (some of the displayed tasks may belong to subprojects).

Tasks in a Scala project

    Build tasks
    -----------
    assemble - Assembles the outputs of this project.
    build - Assembles and tests this project.
    buildDependents - Assembles and tests this project and all projects that depend on it.
    buildNeeded - Assembles and tests this project and all projects it depends on.
    clean - Deletes the build directory.
    jar - Assembles a jar archive containing the main classes.
    
    Documentation tasks
    -------------------
    javadoc - Generates Javadoc API documentation for the main source code.
    scaladoc - Generates scaladoc for the main source code.
    
    Help tasks
    ----------
    dependencies - Displays all dependencies declared in root project 'gradle'.
    dependencyInsight - Displays the insight into a specific dependency in root project 'gradle'.
    help - Displays a help message
    projects - Displays the sub-projects of root project 'gradle'.
    properties - Displays the properties of root project 'gradle'.
    tasks - Displays the tasks runnable from root project 'gradle' (some of the displayed tasks may belong to subprojects).
    
    Verification tasks
    ------------------
    check - Runs all checks.
    test - Runs the unit tests.
    
    Other tasks
    -----------
    scalaConsole - Starts a Scala REPL with the main runtime class path.
    scalaTestConsole - Starts a Scala REPL with the test runtime class path.
    

Let's check out a working build!

THE END

Gradle me this, Gradler!