I see a lot of places in my office where ant tasks
are used to move files from one place to another and also do some tasks on these files.However all this can be done with shell scripts
.
My question is ,
In what cases is ant
preferred over shell scripts
?
What are the benefits of using ant
over a shell scripts
for doing same set of tasks.
One advantage ant
has is that it works on all platforms,other than that are there any performance
related advantages ?
In practice, it boils down to Windows support. If you're in a Unix shop and don't want to introduce new stuff to devs, there are two alternatives i've used with success:
Plain old shell script with Git Bash. Git Bash comes with the Git windows distribution (http://git-scm.com/). If you're doing automation, you can launch shell scripts like so: "C:\Program Files (x86)\Git\bin\sh.exe" --login -i -- ./BUILD
Node script. Again it's one easy installer, it's javascript, and you can use something like ShellJS (https://github.com/arturadib/shelljs) to get very close to Unix shell script / Makefiles.
Your question as to why ANT should be preferred to shell scripts is two-fold:
There are no performance benefits, really. Java is slow for command-line usage.
But..... I would advise against playing the "performance" card. Let's pretend that your application does not support windows (Which is odd considering a Java application should support all plaforms...): I have seen shell script driven deployments decend into chaos attempting to reconcile the various ways different unix operating system commands work. Commands like "tar", "awk", etc can be subtly different which leads to additional platform support logic in your script.
In conclusion I would use neither. I choose a hybrid approach of using groovy for general scripting. It is a java based scripting language and embeds the full power of ANT. Being a java based scripting language means it will work on all platforms. In the interest of fairness it should also be noted that there are other language options. Ruby is certainly worthy of mention since it has spawned a set of configuration management technologies that are well worth evaluation. (See Chef and Puppet)