With ant it's possible to create macros and use them like standard ant tasks.
For instance, in a previous project I was using a proprietary build tool that needed to be launched at the command line. So I created an ant script that was launching that tool from eclipse, and to reuse the invocation logic I created a list of ant macros built one on top of the others; having those scripts helped me to integrate in eclipse the whole development cycle; and finally I ended up starting firefox from ant...
I propose here the lower end of that macros: executing a bash command from ant, and a sample usage.
<property name="env.java.home" value="/usr/lib/jvm/java-1.5.0-sun" />
<macrodef name="bash">
<attribute name="command" />
<sequential>
<exec dir="/bin" executable="/bin/bash">
<env key="JAVA_HOME" value="${env.java.home}"/>
<arg line="-c '@{command}'" />
</exec>
</sequential>
</macrodef>
Sample usage:
<bash command="cd ${env.va.home}; ./va -m${manifest} ${operation}" />
To execute multiple commands for the bash task, it's possible to separate them using ";". Tipically: "cd workdir ; ./dosomething".
Search
Calendar
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Feb | Apr » | |||||
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 | |||||
Archives
Categories
- Android (3)
- Apple (27)
- Books (7)
- Eclipse (14)
- Errors (4)
- Firefox (7)
- Git (2)
- Hardware (17)
- Horror Code (8)
- Internet (21)
- Java (102)
- JavaScript (9)
- Life, universe and everything (46)
- Lifehacks (25)
- Linux (51)
- Opinions (26)
- OSX (6)
- Python (1)
- Software (31)
- Speeches and Conferences (8)
- Unix (4)
- Web (23)
- Windows (19)
Tag Cloud
Android apple architecture Bash configuration CSS Development Düsseldorf Eclipse Git Google Hardware hdr How-To Java JAXB job junit Karmic Linux lion MacBook music Open Source Opinion oracle OSX patterns Pitfalls Practices Resume Security Software Suspend TDD Testing tip tonemapped Tricks Ubuntu unix video Web Workaround XML
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.
Blog License
Blogs I like
Books on the desk
Friends' Blogs
- Antonio Terreno & Valter Bernardini
- Bruno Bossola
- Daniele Galluccio
- Domenico Ventura
- Ed Schepis
- Fabrizio Gianneschi
- Luca Grulla
- Luigi Zanderighi
- Marcello Teodori
- Mida Boghetich
- Muralidharan Chandrasekaran
- Piero Ricca
- Renzo Borgatti
- Simone Bordet
- Simone Bruno
- Uberto Barbini
- Valvolog
- Webtide blogs (Greg Wilkins & Jan Bartel)
Links




















No Responses to “Ant macrodefs”
Please Wait
Leave a Reply