dwdyer / uncommons-antlib

Home | Edit | New

Macros

clean

Deletes all build artifacts for a specified module.

compile

Compiles the main source tree and test source tree for a specified module (dealing with all necessary classpath configuration).

jar

Builds a JAR file for a specified module. Includes main classes and omits test class. Sets the Class-Path and Main-Class manifest properties as required.

source

Builds a source JAR for a specified module, omitting test sources.

test

Runs TestNG unit tests, generates reports using ReportNG and measures code coverage with Cobertura.

javadoc

Simplified Javadoc invocation (requires fewer lines of XML than using the Ant Javadoc task directly).

dist

Copies all build artifacts and dependencies from each module into the “dist” directory so that that directory contains a complete self-contained build of the entire project.

release

Builds release archives (ZIP and TGZ) that contain the contents of the “dist” directory plus any API docs and any text files from the project root (e.g. LICENCE.txt, README.txt, CHANGELOG.txt).

maven-deploy

Constructs a Maven POM and uploads the module JAR file to a Maven repository with source JAR and test source JAR attached.

Usage

Add the uncommons namespace to the root project element:

<project name="myproject" xmlns:uncommons="antlib:org.uncommons.antlib">

Load the macros and taskdefs:

<path id="tool.path">
  <fileset dir="lib" includes="**/*.jar" />
</path>
<taskdef uri="antlib:org.uncommons.antlib"
         resource="org/uncommons/antlib/antlib.xml"
         classpathref="tool.path"/>

Use the macros:

<uncommons:clean module="framework" />
<uncommons:compile module="framework" />
<uncommons:jar module="framework" />
<uncommons:test suites="testng.xml" title="My Unit Test Report" mincoverage="80" />

This example will delete any existing build artifacts from the “framework” module, compile all module sources and test sources (with a classpath that includes any libs in the global lib directory and module lib directory) and build a file called “framework.jar”. It then runs the unit test suites specified by “testng.xml”, generating test and coverage HTML reports. The build will fail if any of the tests fail or if branch or line coverage is below 80%.

Last edited by dwdyer, Mon Jan 04 05:36:54 -0800 2010
Home | Edit | New
Versions: