ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Path elements and properties
Date Thu, 16 Nov 2000 22:30:08 GMT

For that sort of use, move the <property> out of your <init> target and put
it directly under the <project>, before the <path> element.  In point of
fact, most of your <property> elements should be outside of targets.

So you end up with

<project ...>
  <property file="bin/" />

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

  <target name="init" ...>



Untested, so YMMV, but I'm pretty sure this should work.

Glenn McAllister
Software Developer. IBM Toronto Lab, (416) 448-3805
"An approximate answer to the right question is better than the
right answer to the wrong question." - John W. Tukey

Please respond to

Subject:  Path elements and properties


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/" />


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 >

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:

   Buildfile: build.xml


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.


View raw message