【问题标题】:ant script throwing an exception while calculating md5ant脚本在计算md5时抛出异常
【发布时间】:2013-11-26 20:23:14
【问题描述】:

您好,我正在使用 ant 脚本计算特定文件夹中两个文件的 md5。这是我编写的脚本

<?xml version="1.0"?>
<project name="Hello World Project" basedir="." default="info">
    <property name="cms.dir" value="D:\CMS\webclient\components\CMS\Address\AddressSearch" />
    <taskdef resource="net/sf/antcontrib/antlib.xml"/>
    <target name="info">
        <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="," param="file1">
            <sequential>
                <echo>@{file1}</echo>
                <checksum file="@{file1}" todir="./checksum" />
            </sequential>
        </for>
    </target>
</project>

文件名打印正确,但是当我使用同一个文件来计算 md5 时,它会抛出这样的异常

BUILD FAILED
    C:\build.xml:15: The following error occurred while executing this line:
    C:\build.xml:18: Could not find file D:\CMS\webclient\components\CMS\Address\Add
    ressSearch\CMS_addressSearchPopUp.properties
    D:\CMS\webclient\components\CMS\Address\AddressSearch\CMS_addressSearchPopUp.uim
    to generate checksum for.

关于此的任何帮助

【问题讨论】:

  • 您要 md5sum 哪个文件?该错误消息使它看起来找不到名为“D:\CMS\webclient\components\CMS\Address\AddressSearch\CMS_addressSearchPopUp.properties + \n + D:\CMS\webclient\components\CMS\Address\AddressSearch\CMS_addressSearchPopUp.uim”的文件
  • 我将校验和放在 for 循环中,所以我需要计算两个文件的 md5
  • 基于该错误,您的字符串看起来不像您想要的那样被分隔。 sounds.txt 实际上是逗号分隔的,还是该文件每行有一个文件名(即,换行符分隔)?

标签: ant ant-contrib


【解决方案1】:

创建“声音”时使用的是换行符,但使用逗号分隔。

<pathconvert pathsep="${line.separator}" property="sounds" refid="src.files">

然后将其写入文件 - sounds.txt

然后读取文件,用逗号分割。 (","

<for list="${files}" delimiter="," param="file1">

如果我对问题的理解正确,您应该使用换行符进行拆分

   <for list="${files}" delimiter="${line.separator}" param="file1">

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-04-20
    • 2013-07-03
    • 2013-05-24
    • 2014-01-19
    • 1970-01-01
    • 2012-04-08
    • 1970-01-01
    相关资源
    最近更新 更多