在 Ant 中传递分号作为参数 [英] Pass semicolon in Ant as a parameter

查看:27
本文介绍了在 Ant 中传递分号作为参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过";;;"字符串作为我 Ant 任务中的字符串参数:

I want to pass ";;;" string as a string parameter in my Ant task:

<mytask param=";;;"/>

但 Ant 将分号视为特殊符号并引发错误

but Ant consider semicolon as a special symbol and raises an error

java.lang.IllegalArgumentException:非法组引用

我怎么逃跑;将它传递给 Ant 的符号?

how can I escape ; symbol to pass it to Ant?

附言我还发现我不能通过 { 符号,
所以我想知道在 Ant 中转义字符的常用方法是什么?
我试过$;$;$;"但它对我不起作用

p.s. also I found that I can't pass { symbol,
so I wonder what's the common way to escape characters in Ant?
I've tried "$;$;$;" but it's not working for me

更新:示例代码:

public class MyTask extends Task {
    private String value;
    public void setValue(String value) {
        this.value = value;
    }

    public void execute() {
        System.out.println(value);
    }
}

和蚂蚁任务:

<taskdef name="mytask" classpath="build/lib/CustomTasks.jar"
   classname="MyTask"/>
<mytask value=";;;"/>

推荐答案

我对这个示例没有任何问题:

I have not any problem with this sample:

<target name="test_passing_params">
    <antcall target="test_echo">
        <param name="param1" value=";;;"/>
        <param name="param2" value="{"/>
    </antcall>
</target>
<target name="test_echo">
    <echo>param1: ${param1}</echo>
    <echo>param2: ${param2}</echo>
</target>

输出:

回声
参数 1: ;;;
回声
参数 2:{

echo
param1: ;;;
echo
param2: {

mytask 任务的实现可能有问题?

May be problem in implementation of mytask task?

这篇关于在 Ant 中传递分号作为参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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