ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: using loadfile to generate classpathref
Date Thu, 13 Nov 2003 13:19:38 GMT
On Thu, 13 Nov 2003, Euan Guttridge <EGuttridge@buildonline.com>
wrote:

> 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
like

:FULL-PATH-TO-config/../lib/javax-media-jai/jai_codec-1.1.1_01.jar
:FULL-PATH-TO-config/../lib/javax-media-jai/jai_core-1.1.1_01.jar
:FULL-PATH-TO-config/../lib/javax-media/mlibwrapper_jai-1.1.1_01.jar

(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 -->
  <striplinebreaks/>
</loadfile>

and ${path} will look like this

:FULL-PATH-TO-config/../lib/javax-media-jai/jai_codec-1.1.1_01.jar:FULL-PATH-TO-config/../lib/javax-media-jai/jai_core-1.1.1_01.jar:FULL-PATH-TO-config/../lib/javax-media/mlibwrapper_jai-1.1.1_01.jar

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

and that's it.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message