How to correctly set an ant path id?
Given 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 = ${classpa开发者_Python百科th.test}</echo>
</target>
</project>
I would expect the output to be:
main:
[echo] local.builds.dir = C:/scratch/testant
[echo] classpath.test = C:/scratch/testant
BUILD SUCCESSFUL
but it is:
main:
[echo] local.builds.dir = C:/scratch/testant
[echo] classpath.test = ${classpath.test}
BUILD SUCCESSFUL
How do you correctly set 'classpath.test' in this case?
Use this version:
<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>
Easy way:
<echo>classpath.test = ${toString:classpath.test}</echo>
精彩评论