Friday 1 June 2012

Gradle Build automation


Gradle

Gradle is a next generation build automation tool.  "Gradle combines the power and flexibility of Ant with the dependency management and conventions of Maven into a more effective way to build. Powered by a Groovy DSL and packed with innovation, Gradle provides a declarative way to describe all kinds of builds through sensible defaults. Gradle is quickly becoming the build system of choice for many open source projects, leading edge enterprises and legacy automation challenges."

I've used gradle to automate the build of bytepusher4j. I haven't really used it before in a commercial setting (big companies prefer ant or maven), but I can really see how its simplicity is making it more popular.  The entire gradle config for bytepusher4j consists of:

apply plugin: 'java'
apply plugin: 'eclipse'


task zip(type: Zip) {
  from(jar.outputs.files) {
    into('bytepusher/lib')
  }
  from('roms') {
    into('bytepusher/roms')
  }
  from('src/bin') {
    into('bytepusher')
    fileMode(0755)
  }
}

This simple configuration allows a java project to be compiled into a jar file, and then packaged up into a zip file.  It also does dependency management in much the same way as maven (although I don'y need it for bytepusher4j).

Demo

This walkthroguh assumes that you already have  JDK6 ,  GIT and  Eclipse IDE installed.  It also assumes a windows OS, but could equally be applied to linux.

Setup Gradle:
1) Download  gradle and extract zip to c:/tools.  This will create a folder called c:/tools/gradle-1.0-nnn-n.

2) Add a new system environment variable GRADLE_HOME=c:/tools/gradle-1.0-nnn-n

3) Update the PATH environment variable adding %GRADLE_HOME%/bin; to the start

Download git source
4) mkdir c:/src
5) cd c:/src
6) git clone git@github.com:coder36/bytepusher4j.git
7) cd bytepusher4j

Build the code
8) gradle zip
9) gradle eclipse


10) Start Eclipse
11) File ->Import->Existing Projects into Workspace -> Browse
12) Open up C:/src/bytepusherj and select bytepusher4j
13) Finish
17) Select BytePusher.java then hit the green play button to start up the application.


1 comment:

  1. Although this may be great for control within the Bidule patch itself, it makes things more complex outside of the Bidule patch.projector service toronto

    ReplyDelete