ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <peter.kitt.rei...@gmail.com>
Subject Re: Contribute: use zipfileset to extract sub-path of zips
Date Wed, 08 Aug 2007 14:17:22 GMT
Hi Michael,
Can you make a bugzilla entry for your
enhancement.

Peter


On 8/8/07, Michael Zhou <zhouyuehong@21cn.com> wrote:
> Thank you for your reply.
>
> Yes, I can use unzip task to do the similar things, but my improved
> zipfileset is more convenient and faster than simply unzip, copy and re-pack
> approaches.
>
> I usually need to merge some WAR files into one big WAR -- to save
> memories, resources of app-server, and each war represents a sub-dir of
> the big WAR.  But we need to keep the WEB-INF and META-INF dirs top
> level.  Of course we can unzip all WARs and re-pack them into new one,
> but it's much faster to use this new zipfileset to generate it all at
> once.
>
> Hopefully it is useful to other people.
>
> > 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
> >
>
> --
> 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