[英]ant, referring from one property value to another
I have a task inside of my init target that creates a property named "TODAY" : 我的初始化目标中有一个任务,它创建一个名为“ TODAY”的属性:
<tstamp>
<format property="TODAY" pattern="kk:mm:ss-MM-dd-yyyy" locale="en,US"/>
</tstamp>
And a property for where I want my built files to reside named "store.dir" : 还有一个属性,我希望将生成的文件保存在该属性中,名为“ store.dir”:
<property name="store.dir" value="target/${TODAY}"/>
This is ideally what I want... the store.dir property referring to the TODAY property so that I can retarget where I want my packages to be put by modifying one property instead of going through every single jar task. 理想情况下,这就是我想要的...引用TODAY属性的store.dir属性,这样我可以通过修改一个属性(而不是执行每个jar任务)来重新定位要放置软件包的位置。
This doesn't seem to be working though... an echo yields this : 虽然这似乎不起作用...回声产生了这个:
[echo] Making dir : target/${TODAY}
Am I just using the wrong construct here? 我在这里使用错误的结构吗? If I separate them and put them into the dir paths/etc it seems to resolve the properties fine(as it should).
如果我将它们分开并将它们放到dir路径/ etc中,似乎可以很好地解析属性(应该如此)。
Entire relevant section of my config: 我的配置的整个相关部分:
<property name="store.dir" value="target/${TODAY}"/>
<target name="init">
<tstamp>
<format property="TODAY" pattern="kk:mm:ss-MM-dd-yyyy" locale="en,US"/>
</tstamp>
<mkdir dir="bin"/>
<mkdir dir="doc"/>
<echo>Making dir : ${store.dir}</echo>
<mkdir dir="${store.dir}"/>
<copy includeemptydirs="false" todir="bin">
<fileset dir="src">
<exclude name="**/*.launch"/>
<exclude name="**/*.java"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="bin">
<fileset dir="JUnit">
<exclude name="**/*.launch"/>
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
Works : 作品:
<project>
<tstamp>
<format property="TODAY" pattern="kk:mm:ss-MM-dd-yyyy" locale="en,US"/>
</tstamp>
<property name="store.dir" value="target/${TODAY}"/>
<echo>$${store.dir} => ${store.dir}</echo>
</project>
output : 输出:
[echo] ${store.dir} => target/22:13:07-03-17-2014
Maybe the target that want's to use the property store.dir doesn't have the init target in it's dependency chain ? 也许想要使用属性store.dir的目标在依赖链中没有init目标?
-- EDIT after comment and Edit of original question -- -评论后编辑和原始问题编辑-
As fge already mentioned in his comment, your property declaration of store.dir happens before calling the tstamp task which can't work. 正如fge在他的评论中已经提到的那样,您对store.dir的属性声明发生在调用无法执行的tstamp任务之前。 Fix it like that :
像这样修复它:
<target name="init">
<tstamp>
<format property="TODAY" pattern="kk:mm:ss-MM-dd-yyyy" locale="en,US"/>
</tstamp>
<property name="store.dir" value="target/${TODAY}"/>
...
</target>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.