ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank E. Weiss" <fra...@well.com>
Subject Re: Executing a target if a file exists
Date Tue, 29 Jan 2002 19:41:03 GMT
Use the available task and the if/unless attributes of the target. Only targets can be conditionally
run this way, the
available task has to be wrapped in its own target, and the targets need to be chained with
the depends attribute.
Example:

<?xml version="1.0"?>
<project default="cbuild">
    <property name="file" value="file.xml"/>
    <target name="cbuild" depends="test,exists,missing"/>
    <target name="test">
        <available property="file.xml" file="${file}"/>
    </target>
    <target name="exists" if="file.xml">
        <echo message="file exists"/>
    </target>
    <target name="missing" unless="file.xml">
        <echo message="file is missing"/>
    </target>
</project>
========================================


lduperval@microcelli5.com wrote:

> Hello,
>
> I want to do something like this:
>
> <prop name="file" value="file.xml"/>
>
> <target name="build">
>   <condition ifexists="${file}">
>      <ant buildfile="${file}" .../>
>   </condition>
> </target>
>
> So basically, if file.xml exists, the build target tries to compile using it
> as the buildfile. Otherwise, nothing happens.
>
> It looks like it can be done, but I'm not sure how.
>
> Thanks,
>
> L
>
> --
> Laurent Duperval <mailto:lduperval@microcelli5.com>
>
> We'll get along fine as soon as you realize I'm God.
>
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


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


Mime
View raw message