2013-04-04 93 views
1

获得的参数的值我有一个Ant构建任务,其中基于我需要查找基于价值,我在运行时获取的属性文件。例如,我在属性文件中有以下信息:蚂蚁在运行时获取

COMPLETE_LIST=TEST1,TEST2,TEST3 
TEST1=val1 
TEST2=val2 
TEST3=val3 

在我的Ant目标中,我有以下任务。

<target name="target_main"> 
    <foreach param="profile_name" list="${COMPLETE_LIST}" target="target_child"> 
    </foreach> 
</target> 

<target name="target_child"> 
<echo>Printing the value of the param passed ${${profile_name}}</echo> 
</target> 

但是这不起作用。有什么方法可以获得作为参数传递的TEST1的值吗?

回答

1

既然你已经使用ant-contrib,该propertycopy任务将帮助你做你想做的。下面是target_child修改,以适合您的身体:

<target name="target_child"> 
    <propertycopy name="value" from="${profile_name}"/> 
    <echo>Printing the value of the param passed ${${profile_name}}</echo> 
</target> 

输出:

target_main: 

target_child: 
    [echo] Printing the value of the param passed val1 

target_child: 
    [echo] Printing the value of the param passed val2 

target_child: 
    [echo] Printing the value of the param passed val3