<!-- Get list of files in which we're interested. -->
<fileset id = "java.source.set"
dir = "${src}">
<include name = "**/Package/*.java" />
</fileset>
<!-- Get a COMMA separated list of classes to compile. -->
<pathconvert property = "java.source.list"
refid = "java.source.set"
pathsep = ",">
<globmapper from = "${src}/*.@{src.extent}"
to = "*.class" />
</pathconvert>
<!-- Remove ALL dependencies on package classes. -->
<depend srcdir = "${src}"
destdir = "${build}"
includes = "${java.source.list}"
closure = "yes" />
<!-- Get a list of up to date classes. -->
<fileset id = "class.uptodate.set"
dir = "${build}">
<include name = "**/*.class" />
</fileset>
<!-- Get list of source files for up to date classes. -->
<pathconvert property = "java.uptodate.list"
refid = "class.uptodate.set"
pathsep = ",">
<globmapper from="${build}/*.class" to="*.java" />
</pathconvert>
<!-- Compile only those classes in package that are not up to date. -->
<javac srcdir = "${src}"
destdir = "${build}"
classpathref = "compile.classpath"
includes = "${java.source.list}"
excludes = "${java.uptodate.list}"/>
<!-- Get list of directories of class files for package. --:
<pathconvert property = "class.dir.list"
refid = "java.source.set"
pathsep = ",">
<globmapper from = "${src}/*.java"
to = "${build}*" />
</pathconvert>
<!-- Convert directory list to path. -->
<path id = "class.dirs.path">
<dirset dir = "${build}"
includes = "class.dir.list" />
</path>
<!-- Update package documentation. -->
<jdepend outputfile = "${docs}/jdepend-report.txt">
<classpath refid = "compile.classpath" />
<classpath location = "${build}" />
<classespath>
<path refid = "class.dirs.path" />
</classespath>
<exclude name = "java.*" />
<exclude name = "javax.*" />
</jdepend>
注意,在文件集、路径和逗号分隔列表之间有许多转换,只是为了获得不同ant任务所需的正确的“类型”。有没有一种方法可以简化这一点,同时在复杂的目录结构中处理最少的文件?