使用Ant build命令生成目录的校验和 [英] Generate Checksum for directories using Ant build command
本文介绍了使用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>
其他一些一般说明.
- 这不是幂等的.每次运行它时,您将获得一个新值,因为它在新哈希中包含了先前的哈希文件(然后写入了一个新的哈希文件).我建议您将
todir
属性更改为指向其他位置 - 明智地命名目标是一个好主意.请参阅马丁·福勒(Martin Fowler)的这篇很棒的文章,以获取一些命名想法
- 如果没有依赖项,则不需要
depends
属性.
- 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屋!
查看全文