获取目录与蚂蚁修改的文件(Get directories with modified files w

2019-09-29 06:09发布

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

有没有办法?

Answer 1:

整蛊与核心ANT做到这一点。

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

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


文章来源: Get directories with modified files with Ant
标签: ant