【问题标题】:how to get a modified file name using md5 checksum in ant如何在ant中使用md5校验和获取修改后的文件名
【发布时间】:2013-11-27 20:25:44
【问题描述】:

我正在使用这个脚本来计算文件的 md5

<?xml version="1.0"?>
<project name="Hello World Project" basedir="." default="checkChecksum">
    <property name="cms.dir" value="D:\CMS\webclient\WebContent" />
    <taskdef resource="net/sf/antcontrib/antlib.xml"/>

    <target name="createChecksum">
        <checksum todir="./checksum">
            <fileset dir="${cms.dir}"/>
        </checksum>

        <echo>Hello World - Welcome to Apache Ant!</echo>
        <fileset id="src.files" dir="${cms.dir}" casesensitive="yes">
            <include name="**/*.uim"/>
            <include name="**/*.properties"/>
        </fileset>
        <pathconvert pathsep="${line.separator}" property="sounds" refid="src.files">
        </pathconvert>
        <echo file="sounds.txt">${sounds}</echo>
        <loadfile property="files" srcFile="./sounds.txt"/>
        <for list="${files}" delimiter="${line.separator}" param="file1">
            <sequential>
                <echo>@{file1}</echo>
            </sequential>
        </for>
    </target>
</project>

有什么方法可以得到修改的文件的名称,我的意思是 md5 不匹配??

【问题讨论】:

    标签: ant ant-contrib


    【解决方案1】:

    可以使用ANT selector 完成。

    <project name="name" default="print-modified">
    
      <target name="print-modified">
        <apply executable="echo">
          <srcfile/>
          <fileset dir="src">
            <modified/>
          </fileset>
        </apply>
      </target>
    
    </project>
    

    注意:

    • 使用 apply 任务是一种不包括 ant-contrib foreach 任务的迭代方式。

    【讨论】:

    • 填写文件名会在控制台打印???我可以将修改后的文件放在一种像列表这样的数据结构中并将其传递给 ant 任务?????
    • @Deepak_Sharma 你想对这些文件做什么?许多 ANT 旨在对文件集进行操作(例如上面的“应用”任务)。另一方面,ANT contrib 循环任务不是标准 ANT 的一部分,因此,也许您没有以最佳方式解决问题
    • 我想要一个被修改的文件列表,然后使用 ant 任务知道它们在哪个文件夹中
    • @Deepak_Sharma 所以是这样的吗? stackoverflow.com/questions/15688346/…
    • 我可以这样做吗
    猜你喜欢
    • 2010-09-23
    • 1970-01-01
    • 1970-01-01
    • 2013-04-29
    • 1970-01-01
    • 1970-01-01
    • 2012-05-18
    • 2023-04-03
    • 1970-01-01
    相关资源
    最近更新 更多