Using Deco in an ant script

There are several ways to use the Deco tasks:

  • The traditional way:
    <taskdef 
      resource="net/sourceforge/deco/ant/antlib.xml">
      <classpath>
        <pathelement location="YOUR-PATH-TO/deco.jar"/>
        <pathelement location="YOUR-PATH-TO/asm.jar"/>
      </classpath>
    </taskdef>
    

    With this you can use the tasks like plain Ant tasks, they'll live in the default namespace. I.e. if you can run exec without any namespace prefix, you can do so for antunit as well.

  • Similar, but assigning a namespace URI
    <taskdef
      uri="antlib:net.sourceforge.deco.ant" 
      resource="net/sourceforge/deco/ant/antlib.xml">
      <classpath>
        <pathelement location="YOUR-PATH-TO/deco.jar"/>
        <pathelement location="YOUR-PATH-TO/asm.jar"/>
      </classpath>
    </taskdef>
    

    This puts you task into a separate namespace than Ant's namespace. You would use the tasks like

    <project
      xmlns:deco="antlib:net.sourceforge.deco.ant"
      xmlns="antlib:org.apache.tools.ant">
      ...
      <deco:check-compile>
        <artefact location="${target.dir}/${project.name}.jar"/>
            <path refid="compile.path"/>
      </au:assertTrue>
      ...
    

    Or a variation thereof.

  • Using Ant's autodiscovery. Place ant-antunit.jar into a directory and use ant -lib DIR-CONTAINING-THE-JAR or copy it into ANT_HOME/lib - and then in your build file, simply declare the namespace on the project tag:
    <project
      xmlns:deco="antlib:net.sourceforge.deco.ant"
      xmlns="antlib:org.apache.tools.ant">
      ...
    

    And all tasks of this library will automatically be available in the au namespace without any taskdef.