ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Williams <mi...@cortexebusiness.com.au>
Subject writing meta-targets
Date Tue, 20 Nov 2001 04:06:44 GMT
Most of my build-file use a standard pattern of tasks when compiling Java
code:

  - create the output directory
  - run <depend>
  - compile using <javac>
  - copy resource-files into the output directory

I've written a "meta-target" or "recipe" to factor-out this pattern.
It looks like this:

    <target name="meta_compile"> 
        <mkdir dir="${destdir}"/>
        <depend srcdir="${srcdir}"
                destdir="${destdir}"
                cache="${destdir}/../depcache">
            <classpath refid="${classpathref}" />
        </depend>
        <javac srcdir="${srcdir}"
               destdir="${destdir}"
               debug="${javac.debug}"
               deprecation="${javac.deprecation}"
               optimize="${javac.optimize}">
            <classpath refid="${classpathref}" />
        </javac>
        <copy todir="${destdir}"
              overwrite="yes" filtering="yes">
            <fileset dir="${srcdir}"	      <!-- FAILS HERE -->
                     excludes="**/*.java" />  
        </copy>
    </target>

I then use it as:

    <antcall target="meta_compile">
        <param name="srcdir" value="main/java" />
        <param name="destdir" value="build/main/classes" />
        <param name="classpathref" value="compile.classpath" />
    </antcall>

Mostly, this works pretty well, but it falls over when I have multiple
source-directories.

    <antcall target="meta_compile">
        <param name="srcdir" value="ejb/java:build/ejb/java" />
        <param name="destdir" value="build/ejb/classes" />
        <param name="classpathref" value="j2ee.classpath" />
    </antcall>

In this case, I've defined $srcdir as a colon-separated PATH rather than a
single directory.  The <depend> and <javac> targets accept the path quite
happily, but the <fileset> bombs out.  Any suggestions?

Lastly, is there a better way of factoring-out "recipes" like this?

-- 
cheers, Mike


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message