ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject setting a specific compiler
Date Thu, 25 Apr 2002 17:33:11 GMT

Whilst my question is somewhat related to the thread
but it's different enough and I'm stuck enough to ask the question again.

I would like my project to be compiled using the 1.4 JDK as opposed to our regular 1.3.1 compiler
under certain conditions, ideally when a property is set. But from the archives I understand
that I can't do this til Ant 1.5.

I cannot set the JAVA_HOME ev either, as we have a home-grown app somewhat similar to cruise
control that compiles the project as it receives notifs of checkins. Ideally I would like
to do this via the ant build xml files and not have to mess with our autobuilder.

The closest I've got so far is to have two compile targets as follows:

  <target name="compile" depends="init">
	Need two compiles - one for regular JRE and one for the alternate
	With Ant 1.5.1 we could fully specify the compiler as part of the javac task, but not
	the current version (1.4)
    <antcall target="compileRegular">
    <antcall target="compileAlternateJRE">

  <target name="compileRegular" depends="init" unless="javac.AlternateJRE">
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${}" destdir="${dest.dir.javaclasses}" debug="true" deprecation="false"
      <classpath refid="classpath"/>

  <target name="compileAlternateJRE" depends="init" if="javac.AlternateJRE">
    <exec executable="ant">
      <arg line="-buildfile ${ant.file} compileRegular"/>
      <env key="JAVA_HOME" value="${javac.AlternateJRE}"/>
      could set properties via the properties task

So the second target starts a new ant process. Where I'm stuck is that I'm not sure how to
pass all the properties elegantly to the child ant, and it all seems quite hacky.

Is there a better way, or if not does this way seem sensible?

Thanks in advance, Jamie

Visit our website at

This message contains confidential information and is intended only 
for the individual named.  If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail.  Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free 
as information could be intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain viruses.  The sender therefore 
does not accept liability for any errors or omissions in the contents 
of this message which arise as a result of e-mail transmission.  If 
verification is required please request a hard-copy version.  This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities or 
related financial instruments.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message