3.2 Apache ANT Quickstart

The ANT task allows Bundlor to be run from inside any ANT based build system

  1. Define a bundlor namespace

    <project <attribute>name</attribute>=<value>"bundlor-sample-ant"</value>
        <attribute>xmlns:bundlor</attribute>=<value>"antlib:com.springsource.bundlor.ant"</value>>
  2. Import the bundlor task into your build

    <target <attribute>name</attribute>=<value>"bundlor.init"</value>>
      <taskdef <attribute>resource</attribute>=<value>"com/springsource/bundlor/ant/antlib.xml"</value>
          <attribute>uri</attribute>=<value>"antlib:com.springsource.bundlor.ant"</value>>
        <classpath <attribute>id</attribute>=<value>"bundlor.classpath"</value>>
          <fileset <attribute>dir</attribute>=<value>"${bundlor.home}/dist"</value>/>
          <fileset <attribute>dir</attribute>=<value>"${bundlor.home}/lib"</value>/>
        </classpath>
      </taskdef>
    </target>

    This example uses a very simplistic method for building the bundlor task classpath. It is possible to use a dependency manager such as Ivy to better manage the classpath of Bundlor.

  3. Use the bundlor task. See Section 4.2, “Apache ANT Usage” for details about the parameters of the task.

    <bundlor:bundlor
        <attribute>inputPath</attribute>=<value>"${basedir}/target/classes"</value>
        <attribute>outputPath</attribute>=<value>"${basedir}/target/classes"</value>
        <attribute>bundleVersion</attribute>=<value>"1.0.2.BUILD-${timestamp}"</value>
        <attribute>manifestTemplatePath</attribute>=<value>"${basedir}/template.mf"</value>/>