1
我需要处理一个目录,如果它至少有一个修改过的文件。我编写了一个将文件集减少为包含这些文件的目录的唯一列表的块,但是如果有一种方法可以在不使用脚本的情况下执行此操作,那么我认为这会更容易。用Ant修改文件获取目录
有没有办法?
我需要处理一个目录,如果它至少有一个修改过的文件。我编写了一个将文件集减少为包含这些文件的目录的唯一列表的块,但是如果有一种方法可以在不使用脚本的情况下执行此操作,那么我认为这会更容易。用Ant修改文件获取目录
有没有办法?
棘手的核心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>
谢谢,我有一个
http://stackoverflow.com/questions/12111282/can-i-conditionally-stop-an-ant-script-based-on-file -last-modified-time,http://stackoverflow.com/questions/8215089/use-ant-modified-selector-with-arbitrary- – Jayan
Jayan,感谢您的链接,但我已经知道如何获得修改列表文件。我无法弄清楚的是如何将这个列表减少到包含这些文件的目录的唯一列表(没有脚本)。 –