You can run the target in another JVM (we do this all the time). You just need to use fork:
<javac srcdir="${src}" destdir="${build}" fork="yes" />
But I feel that you know this, so what about running the external ANT task as it is, and the rest (let's say you have 3 more javac tasks) in the JVM that you want. This can be achieved by setting the properties file. See javac task
You can use different compilers. This can be set by setting the global property build.compiler, which will affect all tasks within the assembly.
Thus, this property will affect your 3 tasks and run them in the JVM you specify (say 1.7), and you can set JAVA_HOME by default for any task in your external library.
source share