Ant macrodefs

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".


No Responses to “Ant macrodefs”  

  1. No Comments

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>



Calendar

March 2009
M T W T F S S
« Feb   Apr »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Follow me

twitter flickr LinkedIn feed

Subscribe by email

Enter your email address:

Archives


Categories

Tag Cloud


Listening