问题描述
大家好,请看一下这段代码
Hi all please give a look to this code
在我的属性文件中我有win-x86.pc-shared-location=E:\Ant_Scripts
in my properties file i havewin-x86.pc-shared-location=E:\Ant_Scripts
现在我正在尝试从我的 build.xml 中调用 PrintInstallerName_build
,而 PrintInstallerName_build
在 test.xml 中.在 build.xml 文件中,${platform.id} 在调用目标中具有 value=win-x86
并且在被调用目标 param1 中也具有 value=win-x86
Now below i am trying to call PrintInstallerName_build
from my build.xml,while as PrintInstallerName_build
is in test.xml. In build.xml file,${platform.id} has value=win-x86
in the calling target and in called target param1 also has value=win-x86
<target name="PrintInstallerName" >
<echo>PlatForm.Id====>${platform.id}</echo>
<ant antfile="test.xml" target="PrintInstallerName_build">
<property name="param1" value="${platform.id}"/>
</ant>
<target name="PrintInstallerName_build" >
<echo>${param1.pc-shared-location}</echo><!--${param1.pc-shared-location}-->
<echo>${param1}.pc-shared-location}</echo><!--win-x86.pc-shared-location-->
<echo>${win-x86.pc-shared-location}</echo><!--E:\\Ant_Scripts-->
</target>
正如你所看到的,只有最后一条语句给出了正确的输出,但它是硬编码的,我想使用 param1 并且输出应该是 E:\\Ant_Scripts
我试图使用 $ 和 @ 但没有有效,可能是我在某个地方做错了,有人可以帮忙吗,我很震惊,明天就是它的 DOD.
as you can see only the last statement gives correct output but it is hardcoded,i want to use param1 and the output should be E:\\Ant_Scripts
i tried to use $ and @ but none works,may be i am doing wrong somewhere can someone help please,i am struck and tomorrow is its DOD.
推荐答案
<target name="PrintInstallerName_process" >
<echo>${param1}</echo><!--win-x86-->
<macrodef name="testing">
<attribute name="v" default="NOT SET"/>
<element name="some-tasks" optional="yes"/>
<sequential>
<echo>Source Dir of ${param1}: ${@{v}}</echo><!-- Dir of Win-x86:E:\Ant_Scripts-->
<some-tasks/>
</sequential>
</macrodef>
<testing v="${param1}.pc-shared-location">
<some-tasks>
</some-tasks>
</testing>
</target>
这就是它的工作方式,对我来说它仍然很好用 @sudocode
你的提示让我到了那里,所以非常感谢你
this is the way it works and for me it works fine anyways @sudocode
your tip took me there so thank you very much
这篇关于如何在 ant 中访问属性中的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!