ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nate Jones <>
Subject Dynamic Targets
Date Fri, 23 Feb 2001 21:57:32 GMT
Hey all,
  Upon restructuring my company's build scripts, I stumbled upon the
following problem.  There are several packages (individual jars) that must
be built.  They can be done individually or all together.  In my build.xml
file, I have each one specified as a target with the "build" target
running all the others.  Here is an example <target> tag:

    <property name="javasrc.tmpdir" value="../java"/>
    <property name="javaclasses.tmpdir" value="../classes"/>
    <property name="javasrc.basedir" value="../../src/java"/>
    <target name="build-util">
        <mkdir dir="${javasrc.tmpdir}_util/"/>
        <mkdir dir="${javaclasses.tmpdir}_util/"/>
        <!-- Copy the java files -->
        <copy todir="${javasrc.tmpdir}_util">
            <fileset dir="${javasrc.basedir}"
        <!-- Compile the java files -->
        <javac  srcdir="${javasrc.tmpdir}_util"
        <!-- Jar up the class files -->
        <jar    jarfile="../lib/test-util.jar"
        <!-- and clean up after ourselves -->
        <delete dir="${javaclasses.tmpdir}_util"/>
        <delete dir="${javasrc.tmpdir}_util"/>

Pretty simple (I think), but I noticed for all the packages, I will have
basically the same target structure with the "util" keyword changed.  I
was wondering if there is a way of "generalizing" the targets.  For

    <target name="build-%module">
        <mkdir dir="${javasrc.tmpdir}_${module}/"/>
        <mkdir dir="${javaclasses.tmpdir}_${module}/"/>

I had thought about getting ambitious and actually writing my own target
implementation, but I thought I would first ask to see if anyone else has
had this same problem or if there is another, more efficient way of doing
accomplishing this goal with ant...

Thank you.

-- nj

Nate Jones                                      Programmer @ Large     

View raw message