如果目录中至少有一个修改过的文件,我需要处理它。我写了一个块,将文件集减少到包含这些文件的目录的唯一列表,但我认为如果有一种方法可以在没有脚本的情况下执行此操作会更容易。
有办法吗?
答案 0 :(得分:0)
使用核心ANT来做这件事。
以下是使用嵌入式groovy脚本的示例:
<project name="demo" default="process-modified-dirs">
<path id="build.path">
<pathelement location="/path/to/groovy-all/jar/groovy-all-2.1.1.jar"/>
</path>
<fileset id="modifiedfiles" dir="src">
<modified/>
</fileset>
<target name="process-modified-dirs">
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/>
<groovy>
dirs = project.references.modifiedfiles.collect {
new File(it.toString()).parent
}
dirs.unique().each {
ant.echo("Do something with this dir: ${it}")
}
</groovy>
</target>
</project>