有什么办法来产生ANT一个GUID? [英] Is there any way to generate a guid in ANT?
本文介绍了有什么办法来产生ANT一个GUID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Ant脚本来管理了构建过程。对于WiX的我需要制作一个新的GUID,当我们生产的安装程序的新版本。任何人有任何想法如何做到这一点的蚂蚁?使用内置任务的任何答案将是preferable。但是,如果我不得不添加其他文件,这很好。
I have an ant script to manage out build process. For WiX I need to produce a new guid when we produce a new version of the installer. Anyone have any idea how to do this in ANT? Any answer that uses built-in tasks would be preferable. But if I have to add another file, that's fine.
推荐答案
我会使用一个 scriptdef
任务定义简单的JavaScript任务封装了Java的UUID类,像这样:
I'd use a scriptdef
task to define simple javascript task that wraps the Java UUID class, something like this:
<scriptdef name="generateguid" language="javascript">
<attribute name="property" />
<![CDATA[
importClass( java.util.UUID );
project.setProperty( attributes.get( "property" ), UUID.randomUUID() );
]]>
</scriptdef>
<generateguid property="guid1" />
<echo message="${guid1}" />
结果:
[echo] 42dada5a-3c5d-4ace-9315-3df416b31084
如果你有一个合理的最高最新的Ant安装,这应该工作的开箱。
If you have a reasonably up-to-date Ant install, this should work out of the box.
这篇关于有什么办法来产生ANT一个GUID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文