You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ravi Roy <ra...@gmail.com> on 2007/06/14 07:56:54 UTC

How to add a file to existing zip archive into a existing folder

Hi All,

 

I have a zip archive, which I want to update with adding a new file to
specific folder in the zip archive.

 

Example :

 

I have abc.zip containing the directory structure :

     mainfolder\a.jar

     mainfolder\subfolder\b.jar

 

 

My problem is I want to add a c.properties to mainfolder\subfolder. But I
did not find any such example in the documentation.

Though files can be added, but not specified somewhere if somebody wants to
add to a particular directory in zip archive.

 

The following example adds c.properties to the root of testfile.zip but for
me it is not possible to add this file to a specific folder in the said zip
archive.

------------------------------------------------------------------

<project name="test" default="main">

  <property environment="env" />  

 

  <property name="zip.dir" value="C:\testzip" />  

  <target name="main">

    <zip basedir="${zip.dir}"  destfile="${zip.dir}\testfile.zip"
update="true">

        <include name="c.properties" />

    </zip>

  </target>    

 </project>  

 

 

Thanks for any pointers.

Ravi.

 

 

 

 

 

 

 

 

 


RE: How to add a file to existing zip archive into a existingfolder

Posted by Ravi Roy <ra...@gmail.com>.
Thanks Prashant. Excellent, it worked.
Regards.
Ravi.

-----Original Message-----
From: Prashant Reddy [mailto:prashant@pramati.com] 
Sent: Thursday, June 14, 2007 11:58 AM
To: user@ant.apache.org
Subject: Re: How to add a file to existing zip archive into a existingfolder

Use <zip> and <zipfileset> tasks.
        
        <zip destfile="${dist}/abc.zip"> 
            <zipfileset dir="dir" prefix="mainfolder/subfolder"/>
        </zip>

More here : http://ant.apache.org/manual/CoreTypes/zipfileset.html
        
HTH
-Prashant
        
On Thu, 2007-06-14 at 11:26 +0530, Ravi Roy wrote:
> Hi All,
> 
>  
> 
> I have a zip archive, which I want to update with adding a new file to
> specific folder in the zip archive.
> 
>  
> 
> Example :
> 
>  
> 
> I have abc.zip containing the directory structure :
> 
>      mainfolder\a.jar
> 
>      mainfolder\subfolder\b.jar
> 
>  
> 
> 
> 
> My problem is I want to add a c.properties to mainfolder\subfolder. But I
> did not find any such example in the documentation.
> 
> Though files can be added, but not specified somewhere if somebody wants
to
> add to a particular directory in zip archive.
> 
>  
> 
> The following example adds c.properties to the root of testfile.zip but
for
> me it is not possible to add this file to a specific folder in the said
zip
> archive.
> 
> ------------------------------------------------------------------
> 
> <project name="test" default="main">
> 
>   <property environment="env" />  
> 
>  
> 
>   <property name="zip.dir" value="C:\testzip" />  
> 
>   <target name="main">
> 
>     <zip basedir="${zip.dir}"  destfile="${zip.dir}\testfile.zip"
> update="true">
> 
>         <include name="c.properties" />
> 
>     </zip>
> 
>   </target>    
> 
>  </project>  
> 
>  
> 
> 
> 
> Thanks for any pointers.
> 
> Ravi.
> 
>  
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 



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


Re: How to add a file to existing zip archive into a existing folder

Posted by Prashant Reddy <pr...@pramati.com>.
Use <zip> and <zipfileset> tasks.
        
        <zip destfile="${dist}/abc.zip"> 
            <zipfileset dir="dir" prefix="mainfolder/subfolder"/>
        </zip>

More here : http://ant.apache.org/manual/CoreTypes/zipfileset.html
        
HTH
-Prashant
        
On Thu, 2007-06-14 at 11:26 +0530, Ravi Roy wrote:
> Hi All,
> 
>  
> 
> I have a zip archive, which I want to update with adding a new file to
> specific folder in the zip archive.
> 
>  
> 
> Example :
> 
>  
> 
> I have abc.zip containing the directory structure :
> 
>      mainfolder\a.jar
> 
>      mainfolder\subfolder\b.jar
> 
>  
> 
> 
> 
> My problem is I want to add a c.properties to mainfolder\subfolder. But I
> did not find any such example in the documentation.
> 
> Though files can be added, but not specified somewhere if somebody wants to
> add to a particular directory in zip archive.
> 
>  
> 
> The following example adds c.properties to the root of testfile.zip but for
> me it is not possible to add this file to a specific folder in the said zip
> archive.
> 
> ------------------------------------------------------------------
> 
> <project name="test" default="main">
> 
>   <property environment="env" />  
> 
>  
> 
>   <property name="zip.dir" value="C:\testzip" />  
> 
>   <target name="main">
> 
>     <zip basedir="${zip.dir}"  destfile="${zip.dir}\testfile.zip"
> update="true">
> 
>         <include name="c.properties" />
> 
>     </zip>
> 
>   </target>    
> 
>  </project>  
> 
>  
> 
> 
> 
> Thanks for any pointers.
> 
> Ravi.
> 
>  
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 



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