Anthony LoveFrancisco asked when to write a task, versus make an exec call 
versus when to use nant scripting. Here's my thoughts:

Tasks serve at least four functions the other two don't:
1) Portability. (as Anthony mentioned) in some cases abstracting the 
implementation makes something more platform-independant.
2) Reusability. A task can be integrated into NAnt (or NAntContrib) and 
others can use it (similarly across projects internally).
3) Convenience. Some types of activities are difficult or cumbersome to do 
via the other two methods. Writing a task allows the task author to 
provide a facade that simplifies the use of the tool
4) Objectivication. Creating a named entity to refer to an activity. Not 
all tasks wrap single existing tools. Tasks allow us to create named items 
to represent a composite activity, or one that has no specific tool 
correlation.

Exec has benefits the other two don't:
1) Quick access to any command. Writing tasks and scripts may be more 
difficult than calling the command line tool directly, or even via script.
2) Flexibility -- I can call a shell batch file, and vary the batch file 
by machine, or installation -- harder to do that with a task.
3) Familiarity. If a command line tool is well understood, and easy to use 
why reinvent the wheel?

Scripting too has its own benefits
1) More flexible than using targets, faster than writing a task, possibly 
more powerful than simply using exec.
2) Allows for behavior that isn't easily done in tasks, or execs, such as 
looping, or complicated branching logic.

I generally use a task if its available, and use exec when its not . I 
write a task if it seems reusable, and there is enough pain to make the 
task more attractive  than using exec (this comes sooner when the command 
line tool is a PITA to use). So far, I have only used scripting when the 
situation was a single case need, and the nant/exec functionality was too 
limited.

Best,
Bill

William E. Caputo
ThoughtWorks, Inc.
--------
A Plan is a list of things that don't happen






-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to