ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeffrey E Care <ca...@us.ibm.com>
Subject Re: Contribute: use zipfileset to extract sub-path of zips
Date Wed, 08 Aug 2007 12:03:49 GMT
Why bother to go through all that when you can just unzip the file in your 
copy case?

____________________________________________________________________________________________


Jeffrey E. (Jeff) Care 
carej@us.ibm.com 
IBM WebSphere Application Server 
Systems Management Tools Architecture & Development 





Michael Zhou <zhouyuehong@21cn.com> wrote on 08/08/2007 04:38:31 AM:

> I used to build a jar file (or any zip-format file: war, ear, etc.),
> which contents are extracted from other zip files.  For instance,
> zip file src.zip contains:
> 
> +---main
> |   \---org
> |       \---apache
> |               Test.java
> |
> \---test
> 
> I just want the subtree under "main" (not include main directory) to be
> packed into my jar file:
> 
> +---org
>     \---apache
>             Test.java
> 
> So I wrote a build.xml to do this:
> 
> <project default="src-jar">
>     <target name="src-jar">
>         <jar destfile="my-src.jar">
>             <zipfileset src="src.zip" includes="main/"/>
>         </jar>
>     </target>
> </project>
> 
> But the result is not as expected:
> 
> +---main       // I don't want this directory here
>     \---org
>         \---apache
>                 Test.java
> 
> In order to take off the "main" directory, I modified some Ant classes. 
> Attachment is the patch file from Ant 1.7.0 source.
> 
> Usage:
> 
> <project default="src-jar">
>     <target name="src-jar">
>         <jar destfile="my-src.jar">
>             <!-- basedir instead of includes -->
>             <zipfileset src="src.zip" basedir="main/"/>
>         </jar>
>     </target>
> </project>
> 
> This is not the best solution I think.  Because it doesn't support tasks
> other than "zip", "jar", "war".  For example, the following build script
> won't work:
> 
> <project default="copy-src">
>     <target name="copy-src">
>         <copy destfile="srcdir">
>             <zipfileset src="src.zip" basedir="main/"/>
>         </copy>
>     </target>
> </project>
> 
> I suggest to improve class org.apache.tools.zip.ZipFile to support new 
zip
> file format like "src.zip!/main".  By this way, any tasks use zipfileset
> do not need to be changed.
> 
> For example,
> 
> <project default="copy-src">
>     <target name="copy-src">
>         <copy destfile="srcdir">
>             <zipfileset src="src.zip!/main" includes="**/*.java"/>
>         </copy>
>     </target>
> </project>
> 
> Michael Zhou <zhouyuehong@21cn.com>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org

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


Mime
View raw message