ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ondrej Lhotak <olho...@sable.mcgill.ca>
Subject Re: Adding absolute filenames to a jar
Date Wed, 01 Oct 2003 21:53:46 GMT
Thanks for your help, but that doesn't work for me, because I don't know
what the files will be ahead of time (and what the properties will be
set to).

However, poking around a bit more, I found a solution that works,
using <basename> and <dirname>:

<property name="file1" location="/home/olhotak/foo.txt"/>
<property name="file2" location="/tmp/bar.txt"/>

<basename property="file1.base" file="${file1}/>
<dirname property="file1.dir" file="${file1}/>
<basename property="file2.base" file="${file2}/>
<dirname property="file2.dir" file="${file2}/>

<jar destfile="goo.jar">
    <fileset dir="${file1.dir}" includes="${file1.base}"/>
    <fileset dir="${file2.dir}" includes="${file2.base}"/>
</jar>

Ondrej

On Wed, Oct 01, 2003 at 04:33:18PM -0500, Lopez, William wrote:
> ...not tested but try this
> 
> <jar destfile="goo.jar">
>   <fileset dir="/home/olhotak" 
>            includes="foo.txt"/>
>   <fileset dir="/tmp" 
>            includes="bar.txt"/>
> </jar>
> 
> ...will these directories be relative to your build file's base directory?
> If not just copy the files under the main class source dir ( use the basedir
> attribute)...see the Ant Manual jar task doco. 
> 
> HTH,
> -Will
>     
> 
> -----Original Message-----
> From: Ondrej Lhotak [mailto:olhotak@sable.mcgill.ca] 
> Sent: Wednesday, October 01, 2003 10:09 AM
> To: user@ant.apache.org
> Subject: Adding absolute filenames to a jar
> 
> 
> I'm using the <jar> task to create a jar file. The absolute pathnames of the
> files to be included in the jar are in separate properties. How can I get
> the <jar> task to include them? <fileset> requires a dir and a relative
> filename, and I have absolute names.
> 
> For example:
> <property name="file1" location="/home/olhotak/foo.txt"/>
> <property name="file2" location="/tmp/bar.txt"/>
> <jar destfile="goo.jar">
>     <!-- How to include ${file1} and ${file2} in the jar? --> </jar>
> 
> Ondrej
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

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


Mime
View raw message