You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ja...@ubsw.com on 2002/04/25 19:33:11 UTC

setting a specific compiler

Hi

Whilst my question is somewhat related to the thread http://www.mail-archive.com/ant-user@jakarta.apache.org/msg15539.html 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>

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

  <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
    </exec>
  </target>

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 http://www.ubswarburg.com

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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: setting a specific compiler

Posted by Stefan Bodewig <bo...@apache.org>.
On Thu, 25 Apr 2002, Jamie Echlin <Ja...@ubsw.com> wrote:

> 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.

Use plain <javac> without forking, set includeantruntime and
includejavaruntime to false, add tools.jar and rt.jar of JDK 1.4 to
the classpath (or even bootclasspath).  I think this should work in
Ant 1.4.1.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>