Ant 路径/路径元素未正确扩展属性
我的属性 gwt.sdk
在其他地方都可以很好地扩展,但不能在路径/路径元素内:
<target name="setup.gwtenv">
<property environment="env"/>
<condition property="gwt.sdk" value="${env.GWT_SDK}">
<isset property="env.GWT_SDK" />
</condition>
<property name="gwt.sdk" value="/usr/local/gwt" /> <!-- Default value. -->
</target>
<path id="project.class.path">
<pathelement location="${gwt.sdk}/gwt-user.jar"/>
</path>
<target name="libs" depends="setup.gwtenv" description="Copy libs to WEB-INF/lib">
</target>
<target name="javac" depends="libs" description="Compile java source">
<javac srcdir="src" includes="**" encoding="utf-8"
destdir="war/WEB-INF/classes"
source="1.5" target="1.5" nowarn="true"
debug="true" debuglevel="lines,vars,source">
<classpath refid="project.class.path"/>
</javac>
</target>
例如,将 ${gwt.sdk} 的 echo 放在上面可以,但不能在“project.class”内。小路”。这是一个错误,还是我必须做一些我不是的事情?
编辑:我尝试将属性从目标 setup.gwtenv 移至“全局空间”,这有助于规避该问题。
My property gwt.sdk
expands just fine everywhere else, but not inside a path/pathelement:
<target name="setup.gwtenv">
<property environment="env"/>
<condition property="gwt.sdk" value="${env.GWT_SDK}">
<isset property="env.GWT_SDK" />
</condition>
<property name="gwt.sdk" value="/usr/local/gwt" /> <!-- Default value. -->
</target>
<path id="project.class.path">
<pathelement location="${gwt.sdk}/gwt-user.jar"/>
</path>
<target name="libs" depends="setup.gwtenv" description="Copy libs to WEB-INF/lib">
</target>
<target name="javac" depends="libs" description="Compile java source">
<javac srcdir="src" includes="**" encoding="utf-8"
destdir="war/WEB-INF/classes"
source="1.5" target="1.5" nowarn="true"
debug="true" debuglevel="lines,vars,source">
<classpath refid="project.class.path"/>
</javac>
</target>
For instance, placing an echo of ${gwt.sdk} just above works, but not inside "project.class.path". Is it a bug, or do I have to do something that I'm not?
Edit: I tried moving the property out from target setup.gwtenv into "global space", that helped circumvent the problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
扩展不起作用还是只有回声?这是不同的,因为您不能将 echo 任务放置在目标之外。尝试在 javac 目标中使用
作为第一个任务。全局
之前未运行过setup.gwtenv
目标。也许您可以将
移动到setup.gwtenv
中?最后:路径创建时该位置是否存在?否则路径元素将被忽略。
Does the expansion not work or just the echo? This is different, because you cannot place the echo task outside a target. Try
<echo message="${gwt.sdk}"/>
inside the javac target as first task.The global
<path>
has not run thesetup.gwtenv
target before. Maybe you can move the<path>
inside thesetup.gwtenv
?And last: Does the location exist on path creation? Otherwise the pathelement will be ignored.
由于没有其他人回复,我认为解决方案是将
${gwt.sdk}
从setup.gwtenv
移出并进入“全局空间”。Since no-one else replied I take it the solution is to move
${gwt.sdk}
out ofsetup.gwtenv
and into "global space".