alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Friki example source code file (strip-dependencies.xml)

This example Friki source code file (strip-dependencies.xml) 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.

Java - Friki tags/keywords

app, app, can, can, root-class, root-class

The Friki strip-dependencies.xml source code

<project default="strip-dependencies">

  <property name="dest.dir" value="build/lib"/>
  <property name="temp.dir" value="build/stripped"/>
  <property name="jarfile.name" value="${APP}.jar"/>
  <property name="remove.root" value="true"/>

  <target name="strip-dependencies-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>

    <condition property="remove">
      <and>
        <istrue value="${ok}"/>
        <istrue value="${remove.root}"/>
      </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='strip' depends="strip-dependencies-init" if="ok">
    <mkdir dir="${temp.dir}"/>
    <taskdef name="genjar" 
      classname="org.apache.tools.ant.taskdefs.optional.genjar.GenJar" classpath="${classpath}" />
    <genjar destdir="${temp.dir}">
      <classpath refid="classpath"/>
      <class name="${ROOT-CLASS}" />
    </genjar>
  </target>
  
  <target name='remove-root' depends="strip-dependencies-init" if="remove">
    <delete file="${temp.dir}/${ROOT-CLASS}.class"/>
  </target>
  
  <target name='jar' depends="strip" if="ok">
    <mkdir dir="${dest.dir}"/>
    <jar destfile="${dest.dir}/${jarfile.name}" basedir="${temp.dir}"/>
  </target>
    
  <target name='complain' depends="strip-dependencies-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="strip-dependencies" depends="strip, remove-root, jar, complain"/>

</project>

Other Friki examples (source code examples)

Here is a short list of links related to this Friki strip-dependencies.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.