ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Ellsworth <sc...@alodar.com>
Subject javac include that includes only .java files, but recurses?
Date Tue, 02 Oct 2001 23:25:52 GMT
Thanks to the help of Diane Holt, I have something that builds from within 
the hierarchy.  I am now a bit confused about filesets and the ** operator.

My understanding was that ** recursed, and that putting other things on it, 
such as **.java, would give you back the .java files in the named directory 
and below.

It turns out that it gives you the .java files in the directory mentioned, 
and I suspect in any directory whose name ended in .java.

Thus:

Assume I want all java files in org.metagraph.cluster and 
org.metagraph.model and below:

<property 
name="includedFiles" 
value="org/metagraph/cluster/**.java,org/metagraph/model/**.java"/>

then, the javac target does:

   <target name="compile-debug" depends="depend">
     <javac
       srcdir="${src}"
       destdir="${build-debug}"
       classpath="${utilclasspath}"
       includes="${includedFiles}"

Items in certain subdirectories, such as org.metagraph.cluster.isis, were 
not included unless some item in org.metagraph.cluster depended on them.

Using

<property 
name="includedFiles"  value="org/metagraph/cluster/**,org/metagraph/model/**"/>

does work as I expected, but it requires a file scan of a bunch of files 
that javac does not know how to handle.

Is there a better way to create this list that would recurse down the 
directories, but only include .java files?

Scott

Full build.xml:

<project name="metagraph" default="dist" basedir=".">

   <!-- set global properties for this build -->
   <!-- property name="basemgdir" 
value="C:\scott\cvs\Isis\metagraphworking\"/ -->
   <property name="basemgdir" value="..\..\.."/>
   <property name="src" value="${basemgdir}"/>
   <property name="build" value="ant-build"/>
   <property name="build-debug" value="${build}/debug"/>
   <property name="depcache-debug" value="${build}/debug-depcache"/>
   <property name="build-release" value="${build}/release"/>
   <property name="depcache-release" value="${build}/release-depcache"/>
   <property name="libdir" value="${basemgdir}/org/metagraph/lib"/>
   <property name="utilclasspath" 
value="${libdir}/mysql.jar:${libdir}/log4j.jar:${libdir}/jdom.jar"/>
   <property name="dist"  value="dist"/>
   <property 
name="includedFiles" 
value="org/metagraph/cluster/**.java,org/metagraph/model/**.java,org/metagraph/persistence/**.java,org/metagraph/util/**.java"/>
   <property name="baseJarName"  value="metagraph"/>
   <!-- property name="build.compiler" value="jikes"/ -->

   <target name="init">
     <!-- Create the time stamp -->
     <tstamp/>
     <!-- Create the build directory structure used by compile -->
     <mkdir dir="${build-debug}"/>
     <mkdir dir="${depcache-debug}"/>
     <mkdir dir="${build-release}"/>
     <mkdir dir="${depcache-release}"/>
     <!-- Create the dist structure used for results -->
     <mkdir dir="${dist}"/>
   </target>

   <target name="depend" depends="init">
     <depend srcdir="${src}"
       destdir="${build-debug}"
       cache="${depcache-debug}"
       closure="yes"
     />

     <depend srcdir="${src}"
       destdir="${build-release}"
       cache="${depcache-release}"
       closure="yes"
     />
   </target>

   <target name="compile-debug" depends="depend">
     <!-- Compile the java code from ${src} into ${build} -->
     <javac
       debug="on"
       optimize="off"
       srcdir="${src}"
       destdir="${build-debug}"
       classpath="${utilclasspath}"
       includes="${includedFiles}"
     />
   </target>

   <target name="compile-release" depends="depend">
     <!-- Compile the java code from ${src} into ${build} -->
     <javac
       debug="off"
       optimize="on"
       srcdir="${src}"
       destdir="${build-release}"
       classpath="${utilclasspath}"
       includes="${includedFiles}"
     />
   </target>

   <target name="dist-debug" depends="compile-debug">
     <!-- Put everything in ${build-debug} into the 
expImport-${DSTAMP}-debug.jar file -->
     <jar
       jarfile="${dist}/${baseJarName}-${DSTAMP}-debug.jar"
       basedir="${build-debug}"
       compress="false"
     />
   </target>

   <target name="dist-release" depends="compile-release">
     <!-- Put everything in ${build-release} into the 
expImport-${DSTAMP}.jar file -->
     <jar
       jarfile="${dist}/${baseJarName}-${DSTAMP}.jar"
       basedir="${build-release}"
       compress="true"
     />
   </target>

   <target name="dist" depends="dist-debug,dist-release">
   </target>

   <target name="clean">
     <!-- Delete the ${build} and ${dist} directory trees -->
     <delete dir="${build}"/>
     <delete dir="${dist}"/>
   </target>
</project>
Scott Ellsworth
scott@alodar.com


Mime
View raw message