the original question wasn't whether target/task are conditional (they
are).  it was whether there's a way to test the availability of tasks.
there is.  it's documented as:

built-in properties:

nant.task.*     Each task available to nant has a "true" value, e.g.,
nant.task.copy 

however, the DOCS ARE WRONG.  the name of the properties is:
nant.tasks.*

the following works for me:


<!-- sadly, there needs to be this extra step for safety -->
<ifnot propertyexists="nant.tasks.nunit2" >
  <property name="nant.tasks.nunit2" value="false" />
</ifnot>

<!-- main entry -->
<target name="test-task-presence" depends="run-when-nunit" >
  <echo message="in main" />
</target>

<!-- conditional on task availability -->
<target if="${nant.tasks.nunit2}" name="run-when-nunit" >
  <echo message="nunit is avail" />
</target>


HTH
/jean

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Damir Simunic
> Sent: Friday, December 12, 2003 11:47
> To: [EMAIL PROTECTED]
> Subject: RE: [Nant-users] enabling/disabling targets on task 
> availability
> 
> 
> Rodrigo, targets can be conditionally executed with if/unless 
> attributes:
> 
> <call target="test" if="${somevalue}" />
> <call target="test2" unless="${somevalue}"/>
> 
> If/unless can be applied to any task, not just call.
> 
> You can also use if/unless on the target itself:
> 
> <target name="unitest" if="${nunit.present}">
> ...
> </target>
> 
> Damir
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Rodrigo B. de Oliveira
> Sent: Friday, December 12, 2003 5:12 PM
> To: [EMAIL PROTECTED]
> Subject: [Nant-users] enabling/disabling targets on task availability
> 
> How can I test if a task is available for the current build 
> platform and conditionally enable/disable targets?
> 
> Right now my problem is disabling a specific target when the 
> nunit2 is not available.
> 
> Thanks in advance,
> Rodrigo B. de Oliveira
> 
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program. 
> Does SourceForge.net help you be more productive?  Does it 
> help you create better code?  SHARE THE LOVE, and help us 
> help YOU!  Click Here: http://sourceforge.net/donate/ 
> _______________________________________________
> Nant-users mailing list
> [EMAIL PROTECTED] 
> https://lists.sourceforge.net/lists/listinfo/n> ant-users
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program. 
> Does SourceForge.net help you be more productive?  Does it 
> help you create better code?  SHARE THE LOVE, and help us 
> help YOU!  Click Here: http://sourceforge.net/donate/ 
> _______________________________________________
> Nant-users mailing list
> [EMAIL PROTECTED] 
> https://lists.sourceforge.net/lists/listinfo/n> ant-users
> 



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to