ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chad McHenry" <mchen...@gmail.com>
Subject Re: Cross-compilation problem
Date Fri, 22 Feb 2008 20:11:55 GMT
On Fri, Feb 22, 2008 at 12:46 PM, Christian Schröder <cs@deriva.de> wrote:
> Scot P. Floess wrote:
> > Curious, why don't you just use the 1.5 javac but target 1.4?  That
> > should do what you want...  I think all you will need to do is this:
>
> <javac srcdir="src" destdir="classes" source="1.4" target="1.4"/>
> The problem is that the 1.5 javac won't complain if I accidently use
> functions from the 1.5 api.

I've also had to do this. You'll need to specify the "compiler" and
"executable" attributes of the javac task. Using your Test example, this
build file will compile with 1.5, but fail with 1.4. I don't use the
"source" or "target" attributes of javac, since each compilers default
output is what I want. Setting fork="true" is required to use a different
compiler.

...Chad

<project name="compiler-test" default="build">
  <target name="build">
    <antcall target="compile">
      <param name="compiler.id" value="javac1.5"/>
      <param name="compiler.exe" value="C:/java/jdk1.5.0_14/bin/javac.exe"/>
    </antcall>
    <antcall target="compile">
      <param name="compiler.id" value="javac1.4"/>
      <param name="compiler.exe" value="C:/java/jdk1.4.2_16/bin/javac.exe"/>
    </antcall>
  </target>

  <target name="compile">
    <echo message="Compiling with ${compiler.id}"/>
    <delete dir="classes/"/>
    <mkdir dir="classes"/>

    <javac srcdir="src"
           destdir="classes"
           compiler="${compiler.id}"
           executable="${compiler.exe}"
           fork="true"/>
  </target>
</project>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message