How do I use ant with ANTLR 3?

For complete information, see How to use ant with ANTLR3.

  1. download ant-antlr3 task from
  2. copy to where ant can see it. My mac:
    $ sudo cp /usr/local/lib/ant-antlr3.jar /usr/share/ant/lib/
    my linux box:
    $ sudo cp /tmp/ant-antlr3.jar /usr/local/apache-ant-1.8.1/lib/
    Then, this
    $ ant -diagnostics
    should show:
     ANT_HOME/lib jar listing
    ant.home: /usr/share/ant
    ant-antlr.jar (5758 bytes)
    ant-antlr3.jar (20628 bytes)   <---------
  3. make sure antlr2, antlr3, ST are in classpath. All in one is here:
  4. use in build.xml
    	<path id="classpath">
    		<pathelement location="${antlr3.jar}"/>
    		<pathelement location="${ant-antlr3.jar}"/>
    	<target name="antlr" depends="init">
    		<antlr:ant-antlr3 xmlns:antlr="antlib:org/apache/tools/ant/antlr"
    			<classpath refid="classpath"/>