Skip to main content
Jump to: navigation, search


Revision as of 14:42, 3 April 2009 by (Talk | contribs) (Challenges and Risks)

Proposal: Ant buildfile refactorings

Ant macros can be used to achieve re usability of scripts:

A macrodef for compiling Java code using the javac Ant task could look like this:

<macrodef name="m_compile">

  <attribute name="build.dir" default="${build.dir}" />
  <attribute name="" default="default.classpath" />
  <attribute name="src.dir" default="${}" />
     <mkdir dir="@{build.dir}" />
     <javac destdir="@{build.dir}" debug="${debug}"
        <classpath refid="@{}" />
        <src path="@{src.dir}" />



<import file="${buildfiles.dir}/macro/compile.xml" />

This statement imports the XML from the compile.xml file into the place where the import statement is.

Challenges and Risks

It will be interesting to see how deep I can go into developing this enhancement to platform ant. Risks: I don't affevt any of the current functionalities.

Back to the top