Ant path/pathelement not expanding properties correctly

1.2k views Asked by At

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.

2

There are 2 answers

0
Jonas Byström On BEST ANSWER

Since no-one else replied I take it the solution is to move ${gwt.sdk} out of setup.gwtenv and into "global space".

1
Arne Burmeister On

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.