Ant path/pathelement not expanding properties correctly
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.
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 the setup.gwtenv
target before. Maybe you can move the <path>
inside the setup.gwtenv
?
And last: Does the location exist on path creation? Otherwise the pathelement will be ignored.
Since no-one else replied I take it the solution is to move ${gwt.sdk}
out of setup.gwtenv
and into "global space".
精彩评论