是否可以在 Ant 的 build.xml 中替换属性中的文本? [英] Is it possible to replace text in properties in Ant's build.xml?

查看:18
本文介绍了是否可以在 Ant 的 build.xml 中替换属性中的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个属性 app.version,它被设置为 1.2.0(当然,总是在变化)并且需要创建名为something-ver-1_2_0"的 zip 文件.这可能吗?

I have a property, app.version, which is set to 1.2.0 (and, of course, always changing) and need to create zip file with name "something-ver-1_2_0". Is this possible?

推荐答案

您可以使用 pathconvert 任务来替换."使用_"并分配给新属性:

You can use the pathconvert task to replace "." with "_" and assign to a new property:

<?xml version="1.0" encoding="UTF-8"?>
<project>
    <property name="app.version" value="1.2.0"/>

    <pathconvert property="app.version.underscore" dirsep="" pathsep="" description="Replace '.' with '_' and assign value to new property">
        <path path="${app.version}" description="Original app version with dot notation" />

        <!--Pathconvert will try to add the root directory to the "path", so replace with empty string -->
        <map from="${basedir}" to="" />

        <filtermapper>
            <replacestring from="." to="_"/>     
        </filtermapper>

    </pathconvert>

    <echo>${app.version} converted to ${app.version.underscore}</echo>
</project>

这篇关于是否可以在 Ant 的 build.xml 中替换属性中的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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