devdaily home | apple | java | perl | unix | directory | blog

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

<project default="build-packed-jar">

  <property name="base" value=".."/>
  <property name="dest.dir" value="build/lib"/>
  <property name="jarfile.name" value="${APP}.jar"/>

  <target name="init">
    <available property="pack.exists" 
      classname="org.sadun.util.ant.Pack"
       classpath="_ext/pack.jar"/>
    
    <condition property="no-param">
      <not>
        <isset property="ROOT-CLASS"/>
      </not>
    </condition>

    <condition property="no-packer">
      <not>
        <istrue value="${pack.exists}"/>
      </not>
    </condition>
    
    <condition property="ok">
      <and>
        <isfalse value="${no-packer}"/>
        <isfalse value="${no-param}"/>
      </and>
    </condition>
    
  </target>

  <target name='pack' depends="init" if="ok">
    <mkdir dir="${dest.dir}"/>
    <taskdef name="pack" 
      classname="org.sadun.util.ant.Pack" classpath="_ext/pack.jar" />
    <pack 
      classes = "${ROOT-CLASS}"
      targetJar = "${dest.dir}/${jarfile.name}">
      <classpath>
        <pathelement location="build/delivery/classes"/>
        <fileset dir="_lib">
          <include name="**/*.jar"/>
        </fileset>
        <pathelement path="${java.class.path}"/>
      </classpath>
    </pack>
  </target>
  
  <target name='pack-lump' unless="ok">
    <mkdir dir="${dest.dir}"/>
    <jar 
      jarfile="${dest.dir}/${jarfile.name}"
      basedir="build/delivery/classes"/>
    <copy todir="${dest.dir}" filtering="off" overwrite="true">
      <fileset dir="_lib">
        <include name="*.jar"/>
      </fileset>
    </copy>
  </target>
  
  <target name='complain-param' depends="init" if="no-param">
    <echo message="Can not build packed jar file; needs property ROOT-CLASS"/> 
  </target>
  
  <target name='complain-packer' depends="init" if="no-packer">
    <echo message="Can not build packed jar file; needs class org.sadun.util.ant.Pack"/> 
  </target>

  <target name="build-packed-jar" depends="pack, complain-param, complain-packer, pack-lump"/>

</project>




Copyright 1998-2008 Alvin Alexander
All Rights Reserved.
 
devdaily.com is based in louisville, kentucky, and this web site is hosted by godaddy.com