You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Andrew van Renen <av...@hotmail.com> on 2002/08/23 16:42:42 UTC

zipping a single file

I want to add a single file to an archive.  Looking through the docs, I 
expected to be able to write:

	<zip includes="${to}" destfile="${backup_zip}"

but this returned the error: "basedir attribute must be set, or at least one 
fileset must be given!".

So I ended up with:

	<dirname property="to.path" file="${to}"/>
	<basename property="to.filename" file="${to}"/>
	<zip destfile="${backup_zip}">
	    <fileset dir="${to.path}" includes="${to.filename}"/>
	</zip>

That seems a little laborious - is there an easier way?

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: zipping a single file

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
Yes, but only with the CVS version of Ant.  I added a 'file' attribute 
to FileSet such that you can now say this:

	<fileset file="/some/path/to/a/file.txt"/>

And it will create the fileset with only that one file.  Internally it 
does the same thing as the basename and includes, but its much more 
pleasant to work with and you don't have to worry about property 
immutability biting you!  :)

	Erik


Andrew van Renen wrote:
> I want to add a single file to an archive.  Looking through the docs, I 
> expected to be able to write:
> 
>     <zip includes="${to}" destfile="${backup_zip}"
> 
> but this returned the error: "basedir attribute must be set, or at least 
> one fileset must be given!".
> 
> So I ended up with:
> 
>     <dirname property="to.path" file="${to}"/>
>     <basename property="to.filename" file="${to}"/>
>     <zip destfile="${backup_zip}">
>         <fileset dir="${to.path}" includes="${to.filename}"/>
>     </zip>
> 
> That seems a little laborious - is there an easier way?
> 
> _________________________________________________________________
> Send and receive Hotmail on your mobile device: http://mobile.msn.com
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>