<!-- Proguard Properties -->
<property name="obfuscate.dir" value="obf" />
<property name="obfuscate.absolute.dir" location="${obfuscate.dir}" />
<property name="android-jar-preobfuscate" value="${obfuscate.absolute.dir}/original.jar" />
<property name="android-jar-postobfuscate" value="${obfuscate.absolute.dir}/postobf.jar" />
<property name="out.dex.input.absolute.dir" value="${android-jar-postobfuscate}" />

<!-- replaces the post-compile step from ant_rules_r3 -->
<target name="-post-compile" depends="-dex-obfuscate,-dex-no-obfuscate">
</target>

<target name="-dex-no-obfuscate" unless="build.mode.release">
  <mkdir dir="${obfuscate.absolute.dir}" />
  <jar basedir="${out.dir}/classes" destfile="${android-jar-postobfuscate}" />
</target>

<!-- Converts this project's .class files into .dex files -->
<target name="-dex-obfuscate" if="build.mode.release">
  <property name="proguard-jar" value="${proguard.dir}/proguard.jar" />
  <property name="proguard-conf.dir" value="" />
  <property name="proguard-conf.absolute.dir" location="${proguard-conf.dir}" />
  <property name="proguard-conf" value="${proguard-conf.absolute.dir}/procfg.txt" />
  <path id="fullclasspath">
    <path refid="android.target.classpath"/>
    <pathelement path="${external.libs.dir}"/>
  </path>
  <property name="libraryjarpath" refid="fullclasspath"/> 
  <!-- Add Proguard Task -->
  <taskdef resource="proguard/ant/task.properties" classpath="${proguard-jar}" />

  <mkdir dir="${obfuscate.absolute.dir}" />
  <delete file="${android-jar-preobfuscate}"/>
  <delete file="${android-jar-postobfuscate}"/>
  <jar basedir="${out.classes.dir}" destfile="${android-jar-preobfuscate}" />
  <proguard>
    @${proguard-conf}
    -injars ${android-jar-preobfuscate}
    -outjars ${android-jar-postobfuscate}
    -libraryjars ${libraryjarpath}
    -dump ${obfuscate.absolute.dir}/dump.txt
    -printseeds ${obfuscate.absolute.dir}/seeds.txt
    -printusage ${obfuscate.absolute.dir}/usage.txt
    -printmapping ${obfuscate.absolute.dir}/mapping.txt
  </proguard>
</target>