Builds with Gradle, Buildr, Maven, and Ant

Java application deployment

Builds with Gradle, Buildr, Maven, and Ant

By Richard Mayhew

Builds with Gradle, Buildr, Maven, and Ant

We’ll be looking at identical builds for three build tools: gradle, maven, and buildr. There are no differences between the project file structures, only the build directive files were different.

The “test project” was a simple Newton-Raphson implementation for calculating square roots, with one interface, one implementation (using 1.6’s “@Override” in the implementation), and one TestNG test; the goal is to show a simple project with a TestNG dependency. Other dependencies shouldn’t change the build files much.


This is our baseline project configuration, and should represent a close minimum of a Maven 3.0 pom for a project with a dependency on JDK 1.6 and TestNG. It will use the most recent version of TestNG that it is able to find (which is the “[5.14.0,)” version number in the TestNG dependency block.) The file will normally be named pom.xml:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns=""
































The project is built with “mvn package”. It gives a deployable artifact, called “” (the rest of these yield “nr-1.0.jar” files.)


The equivalent gradle configuration file (build.gradle) would look like this:

apply plugin: 'java'

repositories {



dependencies {

    testCompile group: 'org.testng', name: 'testng', version: '5.14+'



The invocation command line is “gradle assemble”.


Buildr’s build file is “buildfile”; the project definition looks like this:

repositories.remote << ''

define 'nr' do


   package :jar

   test.using :testng

   compile.using :source=>'1.6', :target=>'1.6'


The invocation command line is simply “buildr package”.

18 Nov 2010

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.