如何在 Ant 'ReplaceRegExp' 任务中执行数学函数? [英] How can I carry out math functions in the Ant 'ReplaceRegExp' task?

查看:27
本文介绍了如何在 Ant 'ReplaceRegExp' 任务中执行数学函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在来自 Ant 构建脚本的源文件中增加一个数字.我可以使用 ReplaceRegExp 任务来查找我想递增的数字,但是如何在 replace 属性中递增该数字?

I need to increment a number in a source file from an Ant build script. I can use the ReplaceRegExp task to find the number I want to increment, but how do I then increment that number within the replace attribute?

这是我目前得到的:

<replaceregexp file="${basedir}/src/path/to/MyFile.java"
    match="MY_PROPERTY = ([0-9]{1,});"
    replace="MY_PROPERTY = \1;"/>

在replace属性中,我该怎么做

In the replace attribute, how would I do

replace="MY_PROPERTY = (\1 + 1);"

我无法使用 buildnumber 任务将值存储在文件中,因为我已经在同一个构建目标中使用了它.是否有另一个蚂蚁任务可以让我增加一个属性?

I can't use the buildnumber task to store the value in a file since I'm already using that within the same build target. Is there another ant task that will allow me to increment a property?

推荐答案

您可以使用以下内容:

<entry key="revision" type="string" operation="="value="${revision}"/><entry key="build" type="int" operation="+" value="1"/>

所以蚂蚁任务是属性文件.

so the ant task is propertyfile.

这篇关于如何在 Ant 'ReplaceRegExp' 任务中执行数学函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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