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:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to