Ant

Description

Runs the Apache Ant build tool.

This archive contains a DLL compiled using Microsoft's .NET framework 2.0 that contains both the NAnt task as well as an as the MSBuild task to run Ant.

The task and attribute names have been chosen to integrate well within the typical patterns of NAnt and MSBuild, i.e. they start with lowercase in NAnt and uppercase in MSBuild. Some parameters that have been implemented as nested elements in NAnt are only available as attributes in MSBuild - since I didn't manage to figure out how to define nested elements in MSBuild.

Parameters

Attribute Description Required
(a|A)ntHome Where Ant has been installed. No - but then the environment variable ANT_HOME must have been set correctly.
(b|B)uildFile External build file to invoke Ant on. No - defaults to build.xml.
(j|J)avaHome Where Java has been installed. No - will fall back to the JAVA_HOME environment variable and rely on the PATH environment variable if that hasn't been set either.
(l|L)ibPath argument to Ant's -lib command line option No.
AntTargets comma separated list of target names to execute. MSBuild only. No.
AntProperties semicolon separated list of key=value pairs that define Ant properties. MSBuild only. No.

Parameters specified as nested elements - NAnt only

antTarget

antTarget has a single required attribute name - specifies a target to be run.

antProperty

antProperty has two required attributes. name and value that specify name and value of a property that is to be defined in the Ant invocation.

Using

Before you can use the task you need to define it.

NAnt:

  <loadtasks assembly="de.samaflost.AntTask.dll"/>

MSBuild:

  <UsingTask AssemblyFile="de.samaflost.AntTask.dll" TaskName="Ant"/>

Examples

Let Ant execute the default target in the file build.xml in the current directory - assuming ANT_HOME and JAVA_HOME are set correctly.

NAnt:

  <ant/>

MSBuild:

  <Ant/>

Let Ant execute the targets foo and bar in the file antbuild.xml in the current directory, set the Ant property test to the value testvalue - assuming ANT_HOME and JAVA_HOME are set correctly.

NAnt:

  <ant buildFile="antbuild.xml">
    <antTarget name="foo"/>
    <antTarget name="bar"/>
    <antProperty name="test" value="testValue"/>
  </ant>

MSBuild:

  <Ant BuildFile="antbuild.xml" AntTargets="foo,bar" AntProperties="test=testValue"/>

Run the version of Ant installed in /usr/local/ant, specify /opt/java/antlibs/ant-dotnet.jar as -lib argument, use the Java VM installed in /opt/java/home.

NAnt:

  <ant antHome="/usr/local/ant"
    libPath="/opt/java/antlibs/ant-dotnet.jar" javaHome="/opt/java/home"/>

MSBuild:

  <Ant AntHome="/usr/local/ant"
    LibPath="/opt/java/antlibs/ant-dotnet.jar" JavaHome="/opt/java/home"/>

Copyright © 2005-2009 Stefan Bodewig. All rights Reserved.