ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gle...@ca.ibm.com
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/project.properties" />

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

  <target name="init" ...>
    ...
  </target>

  ...

</project>

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 ant-user@jakarta.apache.org

To:   ant-user@jakarta.apache.org
cc:
Subject:  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





Mime
View raw message