Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command are ignored after ant command in batch file

Tags:

batch-file

ant

Following is the bat script code block on which i am working on:

ECHO off 

IF NOT EXIST "%ANT_HOME%" (   

    SET ANT_HOME=%~dp0%build\apache-ant-1.8.2
    SET ANT_BIN=%~dp0%build\apache-ant-1.8.2\bin

    SET PATH | FIND "%ANT_HOME%;%ANT_BIN%"
)
cd "build\Run"
ant -q

cd ../..
echo "Program Terminated!"
exit

Now, my build.xml file is inside this build\Run folder so that i am first navigating to build/Run before running ant -q command (NOTE: I don't want to change this method of navigating).

The moment ant -q command is executed following things happen:

  1. Set the environment variables as the condition.
  2. Change directory to build\Run.
  3. As my build.xml is inside the Run directory the ant -q command run correctly.
  4. Ant executed correctly and not ant script terminates.
  5. Now my current path will be build\Run ! correct <= Here i don't want this after ant is terminated, instead i want to come out from build\Run that's why i used cd../..

But the problem is I am not able to execute the commands after ant -q. This happens be the program control goes from BATCH => ANT.

Is there any way to execute my command after ant command from bat script itself ?

like image 441
Ashwin Hegde Avatar asked May 30 '13 08:05

Ashwin Hegde


1 Answers

You may find that the ant being run is a batch file itself, in which case it simply chains to it (no return).

You should try this instead:

call ant -q

Calling a batch file (as opposed to chaining) will correctly return to the point after which you called it.

like image 64
paxdiablo Avatar answered Sep 28 '22 04:09

paxdiablo