简体   繁体   English

在Ant中-如何将一个属性用作另一个属性的值?

[英]In Ant - how to use one property as value of another property?

Based on a condition, I want a property to have one value or the other. 根据条件,我希望属性具有一个值或另一个值。 The final value of this property is sent as input parameter to another script. 此属性的最终值作为输入参数发送到另一个脚本。

<condition property="localdir" value="../Utils">
    <equals arg1="${isGlobal}" arg2="false"/>
</condition>
<condition property="localdir" value="Utils">
    <equals arg1="${isGlobal}" arg2="true"/>
</condition>
<echo message="localdir after condition is ${localdir}" />

<target name="build_common" description="build common">
    <ant inheritAll="false"  antfile="../Utils/super_build.xml" target="build" >
    <!--line-10-->  <property name="basedir" value="${localdir}"/>          
    </ant>
</target>

The echo of localdir shows the correct value. localdir的回显显示正确的值。 But the basedir in line 10 above does not get set properly. 但是上面第10行中的basedir设置不正确。 Is there some error in the script here? 脚本中是否存在一些错误? I am using Ant 1.8.3. 我正在使用Ant 1.8.3。

Try to set useNativeBasedir="true" in your ant task: 尝试在您的ant任务中设置useNativeBasedir =“ true”:

<target name="build_common" description="build common">
   <ant inheritAll="false"  antfile="../Utils/super_build.xml" target="build" useNativeBasedir="true">
   <!--line-10-->  <property name="basedir" value="${localdir}"/>          
   </ant>
</target>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM