Gradle: make your build flexible

 

 

 

 

 

 

Yegor Bondar

Problem?

 

Ant is so old and can not manage dependencies well (Ivy as a solution)

 

Maven is good but not flexible.

Wanna flexibility?

Put ANT piece into you put.xml!

Gradle

Get scripting abilities from Ant, take dependecy managment from Maven and use Groovy DSL.

key concepts

Expressive build language and deep APi

Flexible conventions

Integration with other build tools

Build lifecycle

  1. Configuration (Creation of Project object)
  2. Initialization (task{})
  3. Execution (task << {})
  1. Create a Settings instance for the build.
  2. Evaluate the settings.gradle script, if present, against the Settings object to configure it.
  3. Use the configured Settings object to create the hierarchy of Project instances.
  4. Finally, evaluate each Project by executing its build.gradle file, if present, against the project. The project are evaluated in such order that a project is evaluated before its child projects.

Tasks

  • A project is essentially a collection of Task objects. 

  • Each task performs some basic piece of work. 

Dependencies

  • A project generally has a number of dependencies. 

  • Project generally produces a number of artifacts, which other projects can use. 

Plugins

  • Plugins can be used to modularise and reuse project configuration. 

Properties

  • Any property or method which your script uses is delegated through to the associated Project object. 

complicated task

  • Application HAVE TO run tests many times against different sources
  • JUnit tests cases come from JAR Dependency
  • Need to work with all this stuff from Java/Groovy application

Conlusions

  • Want flexibility in your build - use Gradle
  • Want to learn new - learn Gradle
  • Want to read a lot of documentation - read Gradle

references

Made with Slides.com