Generating Java from Apache Ant

<< Generating Java from Apache Maven } | Known Limitations >>

To use jADT in Apache Ant you'll need to download both jADT-core-0.3.0.jar and jADT-ant-0.3.0.jar. Then create a taskdef and task like in the following sample build.xml.

    <?xml version="1.0"?>

    <project name="JADTTaskExample" default="compile" basedir=".">
    
      <!-- jadt.classpath is the full path of a directory with both 
           jADT-core-0.3.0.jar and jADT-ant-0.3.0.jar -->
      <property name="jadt.classpath">${basedir}/lib</property>

      <!-- jadt.srcPath is the full path of a directory with .jadt files or
           the path to a single file -->
      <property name="jadt.srcPath">${basedir}/src/main/jadt/</property>
      <!-- or <property name="jadt.srcPath">${basedir}/src/main/jadt/MyStuff.jadt</property> -->

      <!-- jadt.destDir is the full path of a directory where jADT will produce its java output -->
      <property name="jadt.destDir">${basedir}/target/generated-sources/jadt</property>
      
      <taskdef name="jadt" classname="com.pogofish.jadt.ant.JADTAntTask" classpath="${jadt.classpath}" />

      <target name="compile" depeneds="generateJADT">
        <!-- normal compile stuff -->
      </target>
        
      <target name="generateJADT">
        <jadt srcPath="${jadt.srcPath}" destDir = "${jadt.destDir}" />
      </target>
      
      <target name="clean" depends="cleanJADT">
        <!-- normal clean stuff -->
      </target>

      <target name="cleanJADT">
         <delete dir="${jadt.destDir}" />
      </target>
      
    </project>

<< Generating Java from Apache Maven } | Known Limitations >>