ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <>
Subject Re: problems creating a jar
Date Wed, 20 Feb 2008 17:27:54 GMT
Dimitris Mouchritsas wrote:
> Steve Loughran wrote:

>>  <zipfileset dir="build/classes" prefix="WEB-INF/classes"/>
> Steve, creating a tmp dir to create a complicated structure inside a jar 
> file is the recommended approach? Is there a better way to do it? If the 
> tmp dir is the way to go I suppose it's best not to delete this dir, 
> except on a "clean" build right? This would allow for time stamp 
> checking so in case nothing changes the jar wouldn't have to be re-jared 
> every time?

There's no right answer here. Zip files only have 2s worth of 
resolution, so can get a bit confused dependency wise. I think also for 
war files, sticking everything out to place makes it easier to deploy 
stuff in exploded, skipping the <war> step, which gets pretty slow on a 
big project.

for doing redistributable, well, whatever suits.  I tend to do 
copy->tar->zip, because tar retains the accuracy. I also try to set 
permissions up in both the tar and the zip, which needs complex 
<zipfile> work

Here's a snippet. Patterns are shared across zip and tar, each one I set 
up the prefix of the redistributed app (including version) and then pull 
in the various patterns with the right executable flags:

   <target name="zipfilesets" depends="ready-to-release">
     <zipfileset id="doc.files.zf" dir="docs" prefix="${prefix}/docs">
       <patternset refid="docs.pattern" />

     <!--docs in the dist/docs subdir-->
     <zipfileset id="dist.doc.files.zf" dir="${dist}/docs/"
       <patternset refid="docs.pattern" />

     <!-- distributables. Leaves out but docs but includes binaries 
without setting permissions-->
     <zipfileset id="dist.main.zf" dir="${dist}" prefix="${prefix}/dist">
       <include name="**"/>
       <exclude name="lib/**" />
       <exclude name="bin/**"/>
       <exclude name="docs/**"/>
       <exclude name="classes/**"/>
       <patternset refid="excluded.cruft"/>

     <!--binaries. Does not include bin/security -->
     <zipfileset id="dist.unix.bin.zf" dir="${dist}/bin/"
         filemode="${exec}" prefix="${prefix}/dist/bin">
       <patternset refid="unix.bin" />
     <zipfileset id="dist.dos.bin.zf"
         dir="${dist}/bin/" prefix="${prefix}/dist/bin">
       <patternset refid="dos.bin" />
     <zipfileset id="dist.other.bin.zf"
         dir="${dist}/bin/" prefix="${prefix}/dist/bin">
       <patternset refid="other.bin" />
     <zipfileset id="security.unix.bin.zf" dir="${dist}/bin/security" 
       <patternset refid="unix.bin" />
     <zipfileset id="security.dos.bin.zf" dir="${dist}/bin/security"
       <patternset refid="dos.bin" />
     <zipfileset id="security.other.bin.zf" dir="${dist}/bin/security"
       <patternset refid="other.bin" />
     <zipfileset id="unix.bin.zf" dir="bin" filemode="${exec}"
       <patternset refid="unix.bin" />
     <zipfileset id="dos.bin.zf" dir="bin" filemode="${exec}"
       <patternset refid="dos.bin" />
     <zipfileset id="other.bin.zf" dir="bin"
       <patternset refid="other.bin" />
     <!-- source -->
     <zipfileset id="main.zf" dir="."
       <patternset refid="source.pattern" />

     <zipfileset id="dist.lib.zf" dir="${dist}/lib"
       <patternset refid="lib.pattern" />
     <zipfileset id="lib.zf" dir="lib"
       <patternset refid="lib.pattern" />

     <presetdef name="make-dist-zip">
       <zip duplicate="fail">
         <zipfileset refid="dist.main.zf" />
         <zipfileset refid="dist.doc.files.zf" />
         <zipfileset refid="dist.unix.bin.zf" />
         <zipfileset refid="dist.dos.bin.zf" />
         <zipfileset refid="dist.other.bin.zf" />
         <zipfileset refid="dist.lib.zf" />
         <zipfileset refid="security.unix.bin.zf" />
         <zipfileset refid="security.dos.bin.zf" />
         <zipfileset refid="security.other.bin.zf" />

I can then run the preset, or extend it

   <target name="dist-zip" depends="zipfilesets"
       description="distribution zip">
     <make-dist-zip destfile="${}" />

   <target name="dist-unzip" depends="dist-zip">
     <property name="dist.unzip.dir" 
location="${release.unzip.dir}/zip/dist" />
     <delete dir="${dist.unzip.dir}" />
     <mkdir dir="${dist.unzip.dir}" />
     <unzip dest="${dist.unzip.dir}" src="${}"/>

now, dont even get me started on how we build and test the RPMs, as it 
is scary. VMware machine images, bulk scp upload, ssh in as root, rpm 
commands then we run command on the remote machine to walk the new 
init.d round its lifecycle. Its crossed the line between redistributable 
and deployment (especially as the next step is to generate custom RPMs 
with private certificates in)

Steve Loughran        
Author: Ant in Action 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message