macosubuntuanthomebrewant-contrib

How to abstract ant-contrib cross-platform?


Is there a preferred method for calling ant-contrib from your build scripts in such a way that platform differences won't get in the way?

I originally prepared my build from Ubuntu, but when running on OSX with ant-contrib installed via Homebrew, I end up with errors. Seemingly because the contrib jar can't be found.


Solution

  • The preferred way to install Ant-Contrib is mentioned in this page:

    1. Either install it under the lib folder of the Ant installation, and just import it using:

      <taskdef resource="net/sf/antcontrib/antlib.xml"/>
      
    2. Save the Jar file in a known location, perhaps relative to the buildfile, and specify its path:

      <taskdef resource="net/sf/antcontrib/antlib.xml">
        <classpath>
          <pathelement location="path_to_ant_contrib_jar"/>
        </classpath>
      </taskdef>