使用Ant build命令生成目录的校验和 [英] Generate Checksum for directories using Ant build command

查看:140
本文介绍了使用Ant build命令生成目录的校验和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图为目录生成使用的问题.

I tried to generate the checksum for directory using ant.

我尝试了以下命令,但是它在每个文件的每个文件夹内递归生成.

I have tried the below command, but it generates recursively inside each folder for each file.

<target name="default" depends="">
    <echo message="Generating Checksum for each environment" />
    <checksum todir="${target.output.dir}" format="MD5SUM" >
        <fileset dir="${target.output.dir}" />
    </checksum>
</target>

我只想使用Ant命令为特定目录生成一个checksum. 我该怎么办?

I just want to generate one checksum for particular directory using Ant command. How do I do that?

推荐答案

您要使用totalproperty属性.根据文档此属性will hold a checksum of all the checksums and file paths.

You want to use the totalproperty attribute. As per the documentation this property will hold a checksum of all the checksums and file paths.

例如

<target name="hash">
  <checksum todir="x" format="MD5SUM" totalproperty="sum.of.all">
    <fileset dir="x"/>
  </checksum>
  <echo>${sum.of.all}</echo>
</target>

其他一些一般说明.

  • This is not idempotent. Each time you run it you will get a new value because it includes the previous hash file in the new hash (and then writes a new hash file). I suggest that you change the todir attribute to point elsewhere
  • It's a good idea to name your targets meaningfully. See this great article by Martin Fowler for some naming ideas
  • You don't need the depends attribute if there's no dependency.

这篇关于使用Ant build命令生成目录的校验和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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