ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Re: using loadfile to generate classpathref
Date Thu, 13 Nov 2003 13:19:38 GMT
On Thu, 13 Nov 2003, Euan Guttridge <>

> To clarify I have a text file which contains a list of dependency
> jars including path relative to the text file

which wouldn't be a problem if they didn't point to files in a
different directory hierarchy.  I assume the content and location of
the file is untouchable, yes?

OK, use <loadfile>, in particular.

(1) Use <dirname/> to set a property (${dir} for example) to the
directory that contains your dependencies.txt.  Alternatively hardcode
"config" here.

(2) Use <prefixlines prefix="${dir}/"/> - this will make each line
contain an absolute path (not fully resolved, but we are working
towards it).

(3) Use another prefixlines with prefix=":" (or ";", whatever you
prefer) - this will make the loaded file virtually contain something


(4) Use a <striplinebreaks> filter to remove the line breaks.

OK, let's put that together

<dirname property="dir" file="${your-config-file}"/>
<loadfile property="path" srcFile="${your-config-file}">
  <prefixlines prefix=":${dir}/"/> <!-- combined 2 and 3 -->

and ${path} will look like this


Not bad, hm?

OK, now we have a leading : that we don't like and we still have no
path.  We solve the first problem by using a file that doesn't exist -
putting this into the classpath won't do any harm.  The second is
solved by using <pathelement>'s path attribute:

<path id="my-path">
  <pathelement path="I-Do-Not-Exist${path}"/>

and that's it.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message