Troy Laurin wrote:
Since NAnt now does have expressions then that behaviour doesn't make as much sense. You can achieve the same thing by putting the if test inside the target. However with the current behaviour you *can't* prevent both a target and its dependencies from being executed just by using the "if" attribute. This seems like one case where diverging from Ants behaviour might not be a bad thing. Certainly the current behaviour violates the "principle of least suprise".J. Christopher Six wrote:
The "if" attribute definitely seems to be malfunctioning. Here is my test build:
<project name="Test" default="test">
<target name="dependency">
<echo message="This is a dependency. You shouldn't see me
on Linux." />
</target>
<target name="test" depends="dependency" if="${platform::is-win32()}">
<echo message="Is Win32: ${platform::is-win32()}" />
</target>
</project>
The results of running this on Gentoo:
$nant test.build
<...snipped irrelevant messages...>
Target(s) specified: test
dependency:
[echo] This is a dependency. You shouldn't see me on Linux.
BUILD SUCCEEDED
Total time: 0.1 seconds.
This isn't a malfunction, at least if the behaviour is expected to be the same as Ant... Basically, the dependencies of a target are always run before testing the target's condition, because the dependencies may set up the condition.
This is a legacy of Ant not having expressions or an if statement, so the only way to conditionally perform tasks was via this depends/if mechanism:
<target name="foo" depends="foo-test" if="${foo-exists}"> <do-foo /> </target> <target name="foo-test"> <available file="foo.txt" property="foo-exists" /> </target>
Ian
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users