Title: Message

Jo,

 

The code below shows the usage of the ‘if’ attribute in an <echo> element using the _expression_ evaluator.

It should work exactly the same with the <includes> element, which is what you want.

 

 

<project name="Test" default="All">

    <property name="mySwitch" value="on" />

<!--    <property name="mySwitch" value="off" /> -->


    <target name="All">
        <echo message="mySwitch=${mySwitch}" />


        <echo message="Switch is on" if="${mySwitch='on'}" />


        <echo message="Done" />
    </target>

</project>

 

Let me know if you need further help.

 

Thanks,

Noel

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Jo De Greef
Sent: Tuesday, April 13, 2004 6:23 AM
To: [EMAIL PROTECTED]
Subject: [Nant-users] Conditional copy

 

Hi all,

 

I'm trying to create a task that will copy my binaries to a seperate folder after compilation. I created a csv file with the list of files to copy and let Nant iterate through it.

Depending on the value of a property however I want to decide whether or not to copy these files.

 

I can't seem to find any documentation on how to do this exactly.

 

Here's a snippet from my build file:

 

<property name="mySwitch" value="on"/>

<foreach item="Line" in="binaries.csv" delim="," property="sourcePath,destinationPath,filename">
        <copy todir="${binaries.dir}${destinationPath}" overwrite="true">
                <fileset basedir="${string::replace(sourcePath,'[CONFIGURATION]', configuration)}">
                        <includes name="${filename}"
if="test if mySwitch == 'on'" />
                </fileset>
        </copy>
</foreach>

Can someone please tell me what the exact if-statement should look like or where I can find documentation for more info?

 

TIA,
-Jo

ps. I know it's odd to perform the check inside the loop, but this will make sense when I extend the script later on.

Reply via email to