ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sauyet, Scott (OTS-HAR)" <Scott_Sau...@output.net>
Subject RE: Branching on Java version
Date Mon, 09 Jun 2003 16:56:10 GMT
> = Me:

> I have a problem I can't quite figure out.  I think what I want to do is 
> to conditionally use one source file when compiling with Java 1.3 and 
> another when compiling with Java 1.4.  And I don't know how to do that.

Okay, I got it to work, and it wasn't that hard once I remembered that
<target> has "if" and "unless" attributes.  This is what I did:

    <target name="init">
        [ ... ]
        <condition property="oldsource">
            <equals arg1="1.3" arg2="${ant.java.version}"/>
        </condition>
        [ ... ]
    </target>

    <target name="compile" depends="init, use-oldsource, use-newsource">
        [ ... ]
    </target>

    <target name="use-oldsource" depends="init" if="oldsource">
        <echo message="Updating source to use 1.3 code for MyFile"/>
        <copy todir="${my.dir}" file="${etc.dir}/overrides/1.3/MyFile.java"
overwrite="true"/>
    </target>

    <target name="use-newsource" depends="init" unless="oldsource">
        <echo message="Updating source to use 1.4 code for MyFile"/>
        <copy todir="${my.dir}" file="${etc.dir}/overrides/1.4/MyFile.java"
overwrite="true"/>
    </target>

Any suggestions for a cleaner method would be appreciated.

Thanks for all the responses.

  -- Scott

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message