<?xml version="1.0" encoding="UTF-8"?>
<project name="build-scala">

  <!-- Scala SDK (www.scala-lang.org) -->
  <property name="scala-compiler.jar" value="${scala.dir}/lib/scala-compiler.jar" />
  <property name="scala-library.jar" value="${scala.dir}/lib/scala-library.jar" />
  <!-- YGuard SDK (www.yworks.com/products/yguard) -->
  <property name="yguard.jar" value="${yguard.dir}/lib/yguard.jar" />
  <!-- Ant generated files -->
  <property name="scala-library_shr.jar" value="${out.dir}/scala-library_shr.jar" />
  <property name="myapp.jar" value="${out.dir}/${ant.project.name}.jar" />
  
  <path id="scala.path">
    <pathelement path="${scala-compiler.jar}" />
    <pathelement path="${scala-library.jar}" />
  </path>
  <taskdef
    resource="scala/tools/ant/antlib.xml"
    classpathref="scala.path"
  />
  <taskdef
    name="yguard" classname="com.yworks.yguard.YGuardTask"
    classpath="${yguard.jar}"
  />

  <uptodate property="myapp.isUpToDate" targetfile="${myapp.jar}">
    <srcfiles dir="${source.dir}" includes="**/*.scala,**/*.java" />
    <srcfiles dir="${gen.dir}" includes="**/*.java" />
  </uptodate>

  <target name="scala-compile" unless="myapp.isUpToDate">
    <scalac
      srcdir="${source.dir}" includes="**/*.scala"
      destdir="${out.classes.dir}"
      addparams="${scalac.addparams}">
      <classpath>
        <pathelement location="${scala-library.jar}" />
        <pathelement location="${android.jar}" />
        <pathelement location="${out.classes.dir}" />
      </classpath>
    </scalac>
    <jar destfile="${myapp.jar}" basedir="${out.classes.dir}" />
    <yguard>
      <inoutpair in="${scala-library.jar}" out="${scala-library_shr.jar}" />
      <externalclasses>
        <pathelement location="${android.jar}" />
      </externalclasses>
      <shrink logfile="${out.dir}/yshrinklog.xml">
        <entrypointjar name="${myapp.jar}" />
      </shrink>
    </yguard>
    <unjar src="${scala-library_shr.jar}" dest="${out.classes.dir}" />
  </target>

</project>
