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

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

问题描述

我有一个属性,app.version,它被设置为1.2.0(,当然,总是在不断变化),并需要创建压缩文件名称为东西-VER-1_2_0。这可能吗?

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天全站免登陆