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.

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.

Maven

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="http://maven.apache.org/POM/4.0.0"

         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0

             http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

 

    <groupId>com.mayhewr</groupId>

    <artifactId>com.mayhewr.nr.maven</artifactId>

    <version>1.0</version>

    <dependencies>

        <dependency>

            <groupId>org.testng</groupId>

            <artifactId>testng</artifactId>

            <version>[5.14.1,)</version>

            <scope>test</scope>

        </dependency>

    </dependencies>

    <build>

        <plugins>

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-compiler-plugin</artifactId>

                <version>2.1</version>

                <configuration>

                    <source>1.6</source>

                    <target>1.6</target>

                </configuration>

            </plugin>

        </plugins>

    </build>

</project>


 

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

Gradle

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


apply plugin: 'java'

repositories {

    mavenCentral()

}

dependencies {

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

}

version='1.0'


The invocation command line is “gradle assemble”.

Buildr

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


repositories.remote << 'http://www.ibiblio.org/maven2'

define 'nr' do

   project.version='1.0'

   package :jar

   test.using :testng

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

end


The invocation command line is simply “buildr package”.

This was first published in November 2010

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchCloudApplications

SearchSOA

SearchSoftwareQuality

SearchFinancialApplications

SearchSAP

SearchManufacturingERP

Close