You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Dave Inskeep <da...@bea.com> on 2000/11/16 22:57:51 UTC

Path elements and properties

Hi,

I'm trying to create my classpath for compiles, ejbjar, etc using path 
elements. I have an init target that gets properties from a file like so:

   <target name="init">
     <property file="bin/project.properties" />

   </target>

I have a path element (not nested in any targets) that would like to use a 
property from that file, lib.dir, like so:

   <path id="classpath.compile.ref">
     <fileset dir="${lib.dir}" >
         <include name="**/*.jar" />
     </fileset >
   </path>

This works fine if I define lib.dir on the command line when I run ant, 
like "ant -Dlib.dir=lib". If I expect lib.dir to get defined in the 
property file, or even if I just stick a property tag <property 
lib.dir="lib" /> in the init target. When it fails, it never even runs a 
target, it just barfs like so:

   D:\Projects\ADCtoolkit\bin>ant
   Buildfile: build.xml

   BUILD FAILED

   D:\Projects\ADCtoolkit\bin\build.xml:59: 
D:\Projects\ADCtoolkit\${lib.dir} not found.

   Total time: 0 seconds

It appears that the path element is validated before the init target is 
run, so of course lib.dir is not defined, unless I define it on the command 
line. Is the the expected behavior, or am I missing something? The path 
element will be much less useful to me if I can only use properties that 
are defined on the command line.

Thanks,
Dave