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" />
    </zipfileset>

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

<!-- 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"/>
    </zipfileset>

    <!--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>
    <zipfileset id="dist.dos.bin.zf"
        dir="${dist}/bin/" prefix="${prefix}/dist/bin">
      <patternset refid="dos.bin" />
    </zipfileset>
    <zipfileset id="dist.other.bin.zf"
        dir="${dist}/bin/" prefix="${prefix}/dist/bin">
      <patternset refid="other.bin" />
    </zipfileset>
<zipfileset id="security.unix.bin.zf" dir="${dist}/bin/security" filemode="${exec}"
        prefix="${prefix}/dist/bin/security">
      <patternset refid="unix.bin" />
    </zipfileset>
    <zipfileset id="security.dos.bin.zf" dir="${dist}/bin/security"
        prefix="${prefix}/dist/bin/security">
      <patternset refid="dos.bin" />
    </zipfileset>
    <zipfileset id="security.other.bin.zf" dir="${dist}/bin/security"
        prefix="${prefix}/dist/bin/security">
      <patternset refid="other.bin" />
    </zipfileset>
    <zipfileset id="unix.bin.zf" dir="bin" filemode="${exec}"
        prefix="${prefix}/bin">
      <patternset refid="unix.bin" />
    </zipfileset>
    <zipfileset id="dos.bin.zf" dir="bin" filemode="${exec}"
        prefix="${prefix}/bin">
      <patternset refid="dos.bin" />
    </zipfileset>
    <zipfileset id="other.bin.zf" dir="bin"
        prefix="${prefix}/bin">
      <patternset refid="other.bin" />
    </zipfileset>
    <!-- source -->
    <zipfileset id="main.zf" dir="."
        prefix="${prefix}/">
      <patternset refid="source.pattern" />
    </zipfileset>

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


    <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" />
      </zip>
    </presetdef>
  </target>

I can then run the preset, or extend it


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

  <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="${dist.zip}"/>
  </target>

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                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to