2

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 failure 1. Can anyone tell me how can this be achieved?

1 Answer 1

3
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

Sign up to request clarification or add additional context in comments.

1 Comment

Is ant installed correctly? What is shown when you enter ant in the command line?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.