<!-- Ant build script for ProGuard. -->

<project name    = "proguard"
         default = "all"
         basedir = "..">

  <property file = "build/build.properties"/>
  <property name = "src"     value = "src"/>
  <property name = "classes" value = "classes"/>
  <property name = "lib"     value = "lib"/>

  <property name = "ant.jar" value = "${ant.home}/lib/ant.jar"/>
  <property name = "wtk.jar" value = "${wtk.home}/wtklib/kenv.jar"/>

  <target name = "all"     depends = "basic,options"/>
  <target name = "basic"   depends = "proguard,proguardgui,retrace"/>
  <target name = "options" depends = "anttask,wtkplugin"/>

  <target name = "proguard" depends = "classes,lib">
    <javac nowarn      = "true"
           deprecation = "false"
           srcdir      = "${src}"
           destdir     = "${classes}"
           includes    = "proguard/ProGuard.java">
      <compilerarg value = "-Xlint:none"/>
    </javac>

    <copy todir = "${classes}">
      <fileset dir = "${src}">
        <include name = "proguard/*.properties"/>
        <include name = "proguard/*.png"/>
        <include name = "proguard/*.gif"/>
        <include name = "proguard/*.pro"/>
      </fileset>
    </copy>

    <jar jarfile  = "${lib}/proguard.jar"
         manifest = "${src}/proguard/MANIFEST.MF"
         basedir  = "${classes}"
         includes = "proguard/**"/>
  </target>

  <target name = "proguardgui" depends = "proguard">
    <javac nowarn      = "true"
           deprecation = "false"
           srcdir      = "${src}"
           destdir     = "${classes}"
           includes    = "proguard/gui/ProGuardGUI.java">
      <compilerarg value = "-Xlint:none"/>
    </javac>

    <copy todir = "${classes}">
      <fileset dir = "${src}">
        <include name = "proguard/gui/*.properties"/>
        <include name = "proguard/gui/*.png"/>
        <include name = "proguard/gui/*.gif"/>
        <include name = "proguard/gui/*.pro"/>
      </fileset>
    </copy>

    <jar jarfile  = "${lib}/proguardgui.jar"
         manifest = "${src}/proguard/gui/MANIFEST.MF"
         basedir  = "${classes}"
         includes = "proguard/gui/**"/>
  </target>

  <target name = "retrace" depends = "classes,lib">
    <javac nowarn      = "true"
           deprecation = "false"
           srcdir      = "${src}"
           destdir     = "${classes}"
           includes    = "proguard/retrace/ReTrace.java">
      <compilerarg value = "-Xlint:none"/>
    </javac>

    <copy todir = "${classes}">
      <fileset dir = "${src}">
        <include name = "proguard/retrace/*.properties"/>
        <include name = "proguard/retrace/*.png"/>
        <include name = "proguard/retrace/*.gif"/>
        <include name = "proguard/retrace/*.pro"/>
      </fileset>
    </copy>

    <jar jarfile  = "${lib}/retrace.jar"
         manifest = "${src}/proguard/retrace/MANIFEST.MF"
         basedir  = "${classes}"
         includes = "proguard/retrace/**"/>
  </target>

  <target name = "anttask" depends = "proguard">
    <fail message="Please set the value of the property ant.home in the file build/build.properties, if you want to build the optional ProGuard Ant task.">
      <condition>
        <not>
          <available file="${ant.jar}"/>
        </not>
      </condition>
    </fail>

    <javac nowarn      = "true"
           deprecation = "false"
           classpath   = "${ant.jar}"
           srcdir      = "${src}"
           destdir     = "${classes}"
           includes    = "proguard/ant/ProGuardTask.java">
      <compilerarg value = "-Xlint:none"/>
    </javac>

    <copy todir = "${classes}">
      <fileset dir = "${src}">
        <include name = "proguard/ant/*.properties"/>
        <include name = "proguard/ant/*.png"/>
        <include name = "proguard/ant/*.gif"/>
        <include name = "proguard/ant/*.pro"/>
      </fileset>
    </copy>

    <jar jarfile  = "${lib}/proguard.jar"
         update   = "true"
         basedir  = "${classes}"
         includes = "proguard/ant/**"/>
  </target>

  <target name = "wtkplugin" depends = "proguard">
    <fail message="Please set the value of the property wtk.home in the file build/build.properties, if you want to build the optional ProGuard WTK plugin.">
      <condition>
        <not>
          <available file="${wtk.jar}"/>
        </not>
      </condition>
    </fail>

    <javac nowarn      = "true"
           deprecation = "false"
           classpath   = "${wtk.jar}"
           srcdir      = "${src}"
           destdir     = "${classes}"
           includes    = "proguard/wtk/ProGuardObfuscator.java">
      <compilerarg value = "-Xlint:none"/>
    </javac>

    <copy todir = "${classes}">
      <fileset dir = "${src}">
        <include name = "proguard/wtk/*.properties"/>
        <include name = "proguard/wtk/*.png"/>
        <include name = "proguard/wtk/*.gif"/>
        <include name = "proguard/wtk/*.pro"/>
      </fileset>
    </copy>

    <jar jarfile  = "${lib}/proguard.jar"
         update   = "true"
         basedir  = "${classes}"
         includes = "proguard/wtk/**"/>
  </target>

  <target name = "classes">
    <mkdir dir = "${classes}"/>
  </target>

  <target name = "lib">
    <mkdir dir = "${lib}"/>
  </target>

  <target name = "clean">
    <delete>
      <fileset dir = "${classes}"/>
      <fileset dir = "${lib}"/>
    </delete>
  </target>
</project>