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-stripped-jar">

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

  <target name="init">
    <available property="genjar.exists" 
      classname="org.apache.tools.ant.taskdefs.optional.genjar.GenJar"/>
    <condition property="ok">
      <and>
        <istrue value="${genjar.exists}"/>
        <isset property="ROOT-CLASS"/>
      </and>
    </condition>
    
  </target>

  <path id="classpath">
    <pathelement location="build/delivery/classes"/>
    <fileset dir="_ext">
      <include name="**/*.jar"/>
    </fileset>
    <fileset dir="_lib">
      <include name="**/*.jar"/>
    </fileset>
    <pathelement path="${java.class.path}"/>
  </path>
  
  <target name='genjar' depends="init" if="ok">
    <mkdir dir="${dest.dir}"/>
    <taskdef name="genjar" 
      classname="org.apache.tools.ant.taskdefs.optional.genjar.GenJar" classpath="${classpath}" />
    <genjar jarfile="${dest.dir}/${jarfile.name}">
      <classpath refid="classpath"/>
      <class name="${ROOT-CLASS}" />
      <manifest generateEntryAttributes='no' />
    </genjar>
  </target>
  
  <target name='complain' depends="init" unless="ok">
    <echo message="Can not build stripped jar file; needs property ROOT-CLASS and class org.apache.tools.ant.taskdefs.optional.genjar.GenJar"/> 
  </target>

  <target name="build-stripped-jar" depends="genjar, complain"/>

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