获取目录与蚂蚁修改后的文件 [英] Get directories with modified files with Ant

查看:157
本文介绍了获取目录与蚂蚁修改后的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要处理一个目录,如果它有在它的至少一个修改的文件。我写道,减少了文件集包含这些文件的目录的唯一列表块,但我认为这将是更容易,如果有办法做到这一点,而无需脚本。

I need to process a directory if it has at least one modified file in it. I wrote a block that reduces a fileset to a unique list of the directories that contain those files, but I think this would be easier if there was a way to do this without the script.

有没有办法?

推荐答案

整蛊核心ANT做到这一点。

Tricky to do this with core ANT.

下面是使用嵌入式常规脚本的例子:

Here's an example using an embedded groovy script:

<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>

这篇关于获取目录与蚂蚁修改后的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆