<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project>
<project name="com.ibm.wala.dalvik" default="getJars" basedir=".">

  <property name="basews" value="${ws}"/>
  <property name="baseos" value="${os}"/>
  <property name="basearch" value="${arch}"/>
  <property name="basenl" value="${nl}"/>
  
  <!-- Compiler settings. -->
  <property name="javacFailOnError" value="true"/>
  <property name="javacDebugInfo" value="on"/>
  <property name="javacVerbose" value="false"/>
  <property name="logExtension" value=".log"/>
  <property name="compilerArg" value=""/>
  <property name="javacSource" value="1.8"/>
  <property name="javacTarget" value="1.8"/>
  <property name="dir_bootclasspath" value="${java.home}/lib"/>
  <path id="path_bootclasspath">
    <fileset dir="${dir_bootclasspath}">
      
      <include name="*.jar"/>
    </fileset>
  </path>	
  <property name="bootclasspath" refid="path_bootclasspath"/>
  <property name="bundleJavacSource" value="${javacSource}"/>
  <property name="bundleJavacTarget" value="${javacTarget}"/>
  <property name="bundleBootClasspath" value="${bootclasspath}"/>
  
  <target name="CommonsIoPresent" depends="init">
    <available file="${plugin.destination}/lib/commons-io-2.4.jar" property="commons.io.present"/>
  </target>

  <target name="fetchCommonsIo" depends="CommonsIoPresent" unless="commons.io.present">
    <mkdir dir="${plugin.destination}/lib"/>    
    <get src="http://central.maven.org/maven2/commons-io/commons-io/2.4/commons-io-2.4.jar" dest="${plugin.destination}/lib/commons-io-2.4.jar" />
  </target>
  
  <target name="CommonsCliPresent" depends="init">
    <available file="${plugin.destination}/lib/commons-cli-1.4.jar" property="commons.cli.present"/>
  </target>

  <target name="fetchCommonsCli" depends="CommonsCliPresent" unless="commons.cli.present">
    <mkdir dir="${plugin.destination}/lib"/>    
    <get src="http://central.maven.org/maven2/commons-cli/commons-cli/1.4/commons-cli-1.4.jar" dest="${plugin.destination}/lib/commons-cli-1.4.jar" />
  </target>
  
  <target name="DexlibPresent" depends="init">
    <available file="${plugin.destination}/lib/dexlib-1.3.4.jar" property="dexlib.present"/>
  </target>

  <target name="fetchDexlib" depends="DexlibPresent" unless="dexlib.present">
    <mkdir dir="${plugin.destination}/lib"/>
    <get src="https://raw.github.com/msridhar/maven-jars/mvn-repo/net/sridharan/dexlib/1.3.4.custom/dexlib-1.3.4.custom.jar" dest="${plugin.destination}/lib/dexlib-1.3.4.jar"/>
  </target>

  <target name="GuavaPresent" depends="init">
    <available file="${plugin.destination}/lib/guava-13.0.1.jar" property="guava.present"/>
  </target>

  <target name="fetchGuava" depends="GuavaPresent" unless="guava.present">
    <mkdir dir="${plugin.destination}/lib"/>    
    <get src="http://search.maven.org/remotecontent?filepath=com/google/guava/guava/13.0.1/guava-13.0.1.jar" dest="${plugin.destination}/lib/guava-13.0.1.jar"/>
  </target>

  <target name="LogbackPresent" depends="init">
    <available file="${plugin.destination}/lib/logback-core-1.0.9.jar" property="logback.present"/>
  </target>

  <target name="fetchLogback" depends="LogbackPresent" unless="logback.present">
    <mkdir dir="${plugin.destination}/lib"/>    
    <get src="http://central.maven.org/maven2/ch/qos/logback/logback-core/1.0.9/logback-core-1.0.9.jar" dest="${plugin.destination}/lib/logback-core-1.0.9.jar"/>
    <get src="http://central.maven.org/maven2/ch/qos/logback/logback-classic/1.0.9/logback-classic-1.0.9.jar" dest="${plugin.destination}/lib/logback-classic-1.0.9.jar"/>
  </target>

  <target name="Slf4jPresent" depends="init">
    <available file="${plugin.destination}/lib/slf4j-api-1.7.2.jar" property="slf4j.present"/>
  </target>

  <target name="fetchSlf4j" depends="Slf4jPresent" unless="slf4j.present">
    <delete dir="${temp.folder}"/>
    <mkdir dir="${plugin.destination}/lib"/>    
    <get src="http://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.2/slf4j-api-1.7.2.jar" dest="${plugin.destination}/lib/slf4j-api-1.7.2.jar"/>
  </target>

  <target name="getJars" depends="fetchCommonsIo,fetchCommonsCli,fetchGuava,fetchDexlib,fetchLogback,fetchSlf4j" />
  
  <target name="init" depends="properties">
    <condition property="pluginTemp" value="${buildTempFolder}/plugins">
      <isset property="buildTempFolder"/>
    </condition>
    <property name="pluginTemp" value="${basedir}"/>
    <condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.testdata">
      <isset property="buildTempFolder"/>
    </condition>
    <property name="build.result.folder" value="${basedir}"/>
    <property name="temp.folder" value="${basedir}/temp.folder"/>
    <property name="plugin.destination" value="${basedir}"/>
  </target>
  
  <target name="properties" if="eclipse.running">
    <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
  </target>
  
</project>
