更改ANT列表值 [英] Change values of list in ANT

查看:170
本文介绍了更改ANT列表值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实时更改的ANT脚本列表的值。
情况是这样的;

I need to change the values of an ANT-script list in real time. This is the situation;

我有这些属性:

x.y.6.1=something1
x.y.6.2=something2
x.y.6.3=something3

list=6.1,6.2

我想要列表成为列表= something1; something2

I want the list to become list=something1;something2

这是code的要点;

This is the gist of the code;

<target name="target1">
    <foreach list="${list}" target="target2" param="var" delimiter="," />
</target>

<target name="target2">
    <propertycopy name="var" from="x.y.${var}" silent="true"/>
</target>

现在,propertycopy部分作品,但是,它不会让新的价值。
我尝试了许多变化,其中没有工作。
我使用蚂蚁的contrib。

Now, the propertycopy part works, however, it will not keep the new value. I tried many variations, none which worked. I am using ant-contrib.

帮助将非常AP preciated!
亚当

Help would be much appreciated! Adam

推荐答案

我已经解决了这个问题,在一个恶心的方式,但它的伟大工程!

I have solved the problem, in an icky way, but it works great!

<project name="Test" default="main">
    <property file="agent.properties" />
    <property file="temp_updates.txt" />
    <taskdef name="propertycopy" classname="net.sf.antcontrib.property.PropertyCopy" />
    <taskdef name="foreach" classname="net.sf.antcontrib.logic.ForEach" />

    <target name="main">
        <property name="Agent Updates" value="6.1,6.2" />
        <antcall target="create_temp_files" />
        <antcall target="agent_updates_target" />
        <propertycopy name="custom.agent.release.group" from="updates" silent="true" override="true" />
    </target>

    <target name="agent_updates_target">
        <foreach list="${Agent Updates}" target="agent_version_to_path" param="var" delimiter="," />
    </target>

    <target name="agent_version_to_path">
        <propertycopy name="var" from="agent.installer.${var}" silent="true" override="true"/>
        <echo message="${var};" file="temp_updates.txt" append="true" />
    </target>

    <target name="create_temp_files">
        <echo message="updates=" file="temp_updates.txt" />
    </target>

</project>

在另一个文件中,agent.properties我有;

on another file, "agent.properties" I had that;

agent.installer.6.3=something3
agent.installer.6.2=something2
agent.installer.6.1=something1
agent.installer.6.0=...
agent.installer.5.6=...
agent.installer.5.0.12=...
agent.installer.5.0.11=...
agent.installer.5.0.9.5=...
agent.installer.3.8=...
agent.installer.3.7=...

其结果是,创建新文件temp_updates.txt具有

As a result, a new file "temp_updates.txt" was created, having

updates=something1;something2;

然后我加载到实际程序。

Which I then loaded into the actual program.

未必是pretty,但它工作得很好。

May not be pretty, but it works quite well.

感谢您斯科尔和马克·奥康纳你的帮助,我用这些想法拿出这一个。我将率你,但我不能:(不好意思!

Thank you Skoll and Mark O'Connor for all your help, I used those ideas to come up with this one. I would rate you, but I can't :( Sorry!

这篇关于更改ANT列表值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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