Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running ant from a batch file: Later commands don't run

I have a batch file that runs ant and then copies one of the files that were produced:

ant -Dproject.version=1.1.2 release published copy /Y D:\dir1\MyJar.jar   D:\dir2\MyJar.jar 

When I run the batch file, ant runs successfully, but the copy statement never happens, although it will work just fine if I type it in and hit Enter after the ant task has finished.

What is going on here?

like image 681
Paul Reiners Avatar asked Dec 08 '10 18:12

Paul Reiners


People also ask

How do I run an Ant script from a batch file?

Pass the shell script (plus any arguments to the script) as a single command, using -c switch. cmd for batch files. Pass the batch files (plus any arguments to the script) as a single command, using /c switch.

How do I keep cmd from running after a batch file?

Edit your bat file by right clicking on it and select “Edit” from the list. Your file will open in notepad. Now add “PAUSE” word at the end of your bat file. This will keep the Command Prompt window open until you do not press any key.

Can I control a program using a batch file once its been started?

Can I control a program using a batch file once its been started? No. A batch file can only execute or start another program. Once it is started, it cannot perform additional functions within that program.

Can you edit a batch file while it running?

Short answer: yes, batch files can modify themselves whilst running.


1 Answers

I had the same problem once and the magic call did it.

In that batch file of yours try:

call ant -Dproject.version=1.1.2 release published copy /Y D:\dir1\MyJar.jar   D:\dir2\MyJar.jar 

Cannot tell you why it worked, though. Guess it's Microsoft logic.

like image 177
Linus Kleen Avatar answered Sep 18 '22 14:09

Linus Kleen