给出build.xml:
<project name="testant" default="main">
<property name="local.builds.dir" value="C:/scratch/${ant.project.name}"/>
<target name="main">
<echo>local.builds.dir = ${local.builds.dir}</echo>
<path id="classpath.test">
<pathelement location="${local.builds.dir}"/>
</path>
<echo>classpath.test = ${classpath.test}</echo>
</target>
</project>
我希望输出为:
主:
[echo] local.builds.dir = C:/ scratch / testant
[echo] classpath.test = C:/ scratch / testant
建立成功
但它是:
主:
[echo] local.builds.dir = C:/ scratch / testant
[echo] classpath.test = $ {classpath.test}
建立成功
在这种情况下如何正确设置'classpath.test'?
答案 0 :(得分:2)
使用此版本:
<project name="testant" default="main">
<property name="local.builds.dir" value="C:/scratch/${ant.project.name}"/>
<target name="main">
<echo>local.builds.dir = ${local.builds.dir}</echo>
<path id="classpath.test">
<pathelement location="${local.builds.dir}"/>
</path>
<property name="d" refid="classpath.test"/>
<echo>classpath.test = ${d}</echo>
</target>
</project>
答案 1 :(得分:1)
简单方法:
<echo>classpath.test = ${toString:classpath.test}</echo>