<project name="JREbundler" default="jar" basedir=".">

  <property name="version" value="1.0"/>
  <property name="description" value="ANT task for creating Mac OS X application bundle containing JRE"/>    


  <!-- File names -->  
  <property name="JREbundler.jar" value="${ant.project.name}-${version}.jar" />
  <property name="release.zip"    value="${ant.project.name}.zip" />
  <property name="release.tar"    value="${ant.project.name}.tar" />


  <!-- Needs to reference this in order to compile                     -->
  <!-- This path works only for OS X, Windows, and Linux must redefine -->
  <!-- <property name="ant.jar" value="/Developer/Java/Ant/lib/ant.jar" /> -->

   
  <target name="compile" description="Compile the classes">
    
    <mkdir dir="classes"/>
        
    <javac srcdir="core/src" 
           destdir="classes" 
           source="11" 
           deprecation="yes" 
           classpath="${ant.jar}"
           includeAntRuntime="yes">
           <!-- <compilerarg value="-Xlint:unchecked"/> -->
    </javac>
  </target>


  <target name="jar" depends="compile" description="Create JAR file">

    <mkdir dir="build"/>

    <tstamp/>  

    <jar jarfile="build/${JREbundler.jar}" basedir="classes">
        <manifest>
          <attribute name="Version"     value="${version}"/>
          <attribute name="Description" value="${description}"/>
          <attribute name="Build-Date"  value="${TODAY}"/>
          <attribute name="Built-By"    value="${user.name}"/>        
        </manifest>
    </jar>
  </target>


<!-- 
  <target name="javadocs" depends="compile" description="Create JarBundler API">

    <mkdir dir="javadoc"/>

    <javadoc destdir="javadoc" classpath="${ant.jar}">
      <package name="org.rbornat.JREbundler"/>
      <sourcepath location="core/src"/>
    </javadoc>
 </target>
-->

  <target name="release" depends="jar" description="Create zip and tar.gz files">

	<ant dir="./example" target="clean" inheritAll="false"/>
	
    <mkdir dir="release"/>
    <mkdir dir="release/dist"/>
    
    <copy todir="release">
       <fileset dir="dox"/>
    </copy>
    

    <!-- Make this file easy to find in the distribution -->
    <move file="build/${JREbundler.jar}" tofile="${JREbundler.jar}"/>
    
    <zip destfile="release/dist/${release.zip}">
      <zipfileset prefix="${ant.project.name}-${version}/" dir="${basedir}" excludes="CVS">
        <include name="LICENSE.TXT"/>
        <include name="dox/**"/>
        <include name="build.xml"/>
        <include name="src/**"/>
        <include name="example/**"/>
        <include name="${JREbundler.jar}"/> 
      </zipfileset>
    </zip>

    <tar destfile="release/dist/${release.tar}">
      <tarfileset prefix="${ant.project.name}-${version}/" dir="${basedir}">
        <include name="LICENSE.TXT"/>
        <include name="dox/**"/>
        <include name="build.xml"/>
        <include name="src/**"/>
        <include name="example/**"/>
        <include name="${JREbundler.jar}"/> 
      </tarfileset>	
    </tar>

    <!-- Compress the tar -->
    <gzip src="release/dist/${release.tar}" zipfile="release/dist/${release.tar}.gz"/>

    <!-- Remove the intermediate tar -->
    <delete quiet="true" file="release/dist/${release.tar}" />

    <!-- Move the product back -->
    <move file="${JREbundler.jar}" tofile="build/${JREbundler.jar}"/>


  </target>


  <target name="simple" depends="jar" description="Build an example application">
	<ant dir="./example" target="simple" inheritAll="false">
      <property name="JREbundler.jar" value="${basedir}/build/${JREbundler.jar}" />
	</ant>
  </target>


  <target name="complex" depends="jar" description="Build an example application">
	<ant dir="./example" target="complex" inheritAll="false">
      <property name="JREbundler.jar" value="${basedir}/build/${JREbundler.jar}" />
	</ant>
  </target>


  <target name="clean" description="Clean up">
    <delete dir="classes"/> 
    <delete dir="build"/> 
    <delete dir="javadoc"/>
    <delete dir="release"/> 
	<ant dir="examples" target="clean" inheritAll="false"/>
  </target>

</project>
