【问题标题】:How in Ant output values of properties?在 Ant 中如何输出属性值?
【发布时间】:2012-01-03 20:50:06
【问题描述】:

在 Ant 中退出任务 Echo:

<echo message="Hello, world"/>

但它似乎没用。我需要检查 ant 文件中的值。 例如。

 <property file="${user.home}/build.properties"/>
 <echo message="${file}" />

但我只收到:

 [echo] ${file}

如何让 Ant 显示文件的值?

【问题讨论】:

    标签: ant echo default-value


    【解决方案1】:

    此声明:

    <property file="${user.home}/build.properties"/>
    

    Reads a property file(即该文件中的所有属性),并且不设置名为file的属性。

    这是正确的。你先设置一个属性,然后回显它:

    <property name="file" value="${user.home}/build.properties"/>
    <echo message="${file}" />
    

    【讨论】:

      【解决方案2】:

      您收到了${file} 的回声,因为您没有设置该属性。你的属性文件中是否有一行写着file = someValue?

      也许你想做这样的事情?

      <property name="property.file" value="${user.home}/build.properties"/>
      <property file="${property.file}"/>
      <echo message="My property file is called &quot;${property.file}&quot;"/>
      

      【讨论】:

        猜你喜欢
        • 2012-03-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-09-08
        • 1970-01-01
        相关资源
        最近更新 更多