<!--
/* License
 * 
 * Copyright 1994-2004 Sun Microsystems, Inc. All Rights Reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *  
 *  * Redistribution of source code must retain the above copyright notice,
 *      this list of conditions and the following disclaimer.
 * 
 *  * Redistribution in binary form must reproduce the above copyright notice,
 *      this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 * 
 * Neither the name of Sun Microsystems, Inc. or the names of contributors
 * may be used to endorse or promote products derived from this software
 * without specific prior written permission.
 *  
 * This software is provided "AS IS," without a warranty of any kind. ALL
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
 * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
 * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN")
 * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
 * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
 * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
 * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
 *  
 * You acknowledge that this software is not designed, licensed or intended
 * for use in the design, construction, operation or maintenance of any
 * nuclear facility. 
 */
-->

<project name="MyProject" default="dist" basedir="..">
  <property name="midp" value="/lang/j2mewtk"/>
  <property name="midp_lib" value="${midp}/lib/midpapi.zip"/>

  <property name="jax" value="/lang/jax61"/>

    <target name="init">
      <tstamp/>
  </target>
  
  <target name="compile" depends="init">
    <mkdir dir="build/classes"/>
    <javac destdir="build/classes" srcdir="src"
        bootclasspath="${midp_lib}" target="1.1"/>
  </target>
  
  <target name="obfuscate" depends="compile">
    <mkdir dir="build/jax"/>
    
    <java fork="yes" classname="com.ibm.jax.Batch"
        classpath="${jax};${midp_lib}">
      <sysproperty key="HOME" value=".."/>
      <sysproperty key="MIDP_HOME" value="${midp}"/>
      <arg line="build/myprog.jax"/>
    </java>
    
    <mkdir dir="build/obfuscated"/>
    <unjar src="build/jax/myprog_jax.zip"
        dest="build/obfuscated"/>
   </target>

<!-- Change the depend here to "compile" if you don't 
wish to use an obfuscator -->
<target name="preverify" depends="obfuscate">
      <mkdir dir="build/preverified"/>
      <exec executable="${midp}/bin/preverify">
        <arg line="-classpath ${midp_lib}"/>
        <arg line="-d build/preverified"/>
        <arg line="build/classes"/>
      </exec>
</target>

<target name="dist" depends="preverify">
    <mkdir dir="build/bin"/>
    <jar basedir="build/preverified"
        jarfile="build/bin/MyProj.jar"
        manifest="bin/MANIFEST.MF">
      <fileset dir="res"/>
    </jar>
    <copy file="bin/MyProj.jad"
        tofile="build/bin/MyProj.jad"/>
</target>

<target name="run" depends="dist">
    <exec executable="${midp}/bin/emulator">
      <arg line="-Xdescriptor:build/bin/MyProj.jad"/>
    </exec>
</target>

</project>