Overview
Within a Java program, each Jamon template is represented as an instance of a class specific to that template. In order for your program to compile, Jamon templates need to be translated into Java source classes, and those generated Java sources need to be included in the build of your project.
Assumptions
- Java source files are located in the directory '
src
' under your main project directory - Jamon templates are located in the directory
tree named '
templates
' - generated classes are generated into
'
classes
' - Java source files corresponding to Jamon
templates will be generated into the directory
'
tempsrc
'.
Building with Ant
First, ensure you have the Jamon task properly defined, which could be accomplished by including the following in thebuild.xml
file:
<path id="jamontaskcp"> <pathelement file="/path/to/jamon-runtime.jar"/> <pathelement file="/path/to/jamon-api.jar"/> <pathelement file="/path/to/jamon-procesor.jar"/> <pathelement file="/path/to/jamon-anttask.jar"/> </path> <taskdef name="jamon" classname="org.jamon.ant.JamonTask" classpathref="${jamontaskcp}"/>To generate the Java sources, include the following target:
<target name="templates"> <mkdir dir="tempsrc" /> <jamon destdir="tempsrc" srcdir="templates" /> </target>To compile the project:
<target name="compile" depends="templates"> <javac destdir="classes" classpath="/path/to/jamon-runtime.jar" > <src path="src"/> <src path="tempsrc"/> </javac> </target>