Running an ANT script in a .bat/.cmd file under Windows

Author: Kasper B. Graversen, 26/08/08
Keywords: ANT, Build script, Bat file, Cmd file
Abstract: This article explains how to run an ANT script in a .bat or a .cmd file under Windows.
subscribe to my RSS feed


Bookmark and Share


Running an ANT script in a .bat/.cmd file under Windows

This is just a quick tip for Windows users who are running Ant. The other day, I wanted to first execute an Ant script, and then start a Jetty web server. The naive approach is to do something similar to
ant -q -f c:\coding\project-x\build.xml
java -jar start_jetty.jar
You won't get very far with such an approach. After the Ant script has executed, the script will stop running. The secret is to use the Windows command CALL hence you need to change the above script to
CALL ant -q -f c:\coding\project-x\build.xml
java -jar start_jetty.jar
Then things run as expected. Basically, the CALL command enables a user to execute a batch file from within another batch file.



Comments

If you have any comments to this article, please drop me a mail at firstclassthoughts at gmail dot com please indicate if I can't publish whole or parts of your comment on the site.


If you like this site consider subscribing to my RSS feed or how about subscribing by Email.


Help spread the word

Share this post on your favorite social bookmarking sites:
If you enjoyed this article, found it thought provoking, educative or otherwise good, please link to this page from your page or social bookmarking page. If you have any texts you think are worth publishing on First Class Thoughts, don't hesitate to send me a mail! Quality always welcome.


Bookmark and Share


The most recent contributions
20/05/09 Board Game Jungle speed / Arriba Review of the cool game "Jungle Speed" aka. "Arriba".
16/05/09 Danish Twin words "Twin words" are words that not only have multiple meanings, they must be composed next to each other in meaningful sentences. This article explores the concept of twin words.
14/05/09 English Twin words "Twin words" are words that not only have multiple meanings, they must be composed next to each other in meaningful sentences. This article explores the concept of twin words.
04/05/09 'Office space' extras Crazy stuff about the funny movie "Office space".
Nothing of interest? Try browsing the entire article archive...