Invoking an Ant task using a specific JVM
Sometimes you’d like to invoke Ant using a specific JVM, maybe because you want to compile using a well specified JDK implementation.
I solved this problem with a task like this:
<macrodef name="ant-jvm">
<attribute name="target" />
<attribute name="jvm" />
<attribute name="antfile" default="build.xml"/>
<attribute name="basedir" default="."/>
<attribute name="args" default="-Dsample.value=xxx"/>
<attribute name="taskname" default="ant"/>
<sequential>
<java classname="org.apache.tools.ant.launch.Launcher"
fork="true"
jvm="@{jvm}"
failonerror="true"
dir="@{basedir}"
timeout="99999999"
taskname="@{taskname}">
<classpath>
<pathelement location="${ant.home}/lib/ant-launcher.jar"/>
</classpath>
<arg value="-buildfile"/>
<arg file="@{antfile}"/>
<arg value="@{args}"/>
<arg value="@{target}"/>
<arg value="-Dbasedir=@{basedir}"/>
</java>
</sequential>
</macrodef>
You may use it instead of <ant> task and allows you to specify the jvm to use, something like this:
<ant-jvm target="-do-ejbdoclet" jvm="${java-1.3}/bin/java" />
Quick and dirty, but it works ![]()