I need to run an ant script from a shell script and if the ant script is executed successfully I must get the return code 0 or in case of fai开发者_C百科lure 1. Can anyone tell me how can this be achieved?
cd ~/yoursourcedir/
ant
if [[ $? -ne 0 ]]
then
echo "error happend"
fi
$?
contains the error code of your last command, in this case ant
.
-ne 0
means not equal 0, so if any error happened, execute the echo
.
You can specify the standard paramters to ant, i.e. your buildfile:
ant -buildfile build.xml
Summary of ant run options
精彩评论