How to macro-ify ant targets?
- by Jonas Byström
I want to be able to have different targets doing nearly the same thing, as so:
ant build <- this would be a normal (default) build
ant safari <- building the safari target.
The targets look like this:
<target name="build" depends="javac" description="GWT compile to JavaScript">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
</classpath>
<jvmarg value="-Xmx256M"/>
<arg value="${lhs.target}"/>
</java>
</target>
<target name="safari" depends="javac" description="GWT compile to Safari/JavaScript">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
</classpath>
<jvmarg value="-Xmx256M"/>
<arg value="${lhs.safari.target}"/>
</java>
</target>
(Nevermind the first thought that strikes: throw out ant! That's not an option just yet.) I tried using macrodef, but got a strange error message (even though the message didn't imply it, it think it had to do with putting a target in sequential). I don't want to do ant -Dwhatever=nevermind. Any ideas?