<?xml version="1.0"?>
<project name="smartpgp" default="convert" basedir=".">
  <description>Ant build for SmartPGP applet</description>
  <property name="src" location="src"/>
  <property name="build" location="build"/>
  <property file="javacard.properties"/>
  <property name="JAVA_PACKAGE" value="fr.anssi.smartpgp"/>
  <property name="JAVA_PACKAGE_DIR" value="fr/anssi/smartpgp/"/>
  <property name="APPLET_NAME" value="SmartPGPApplet"/>
  <property name="PACKAGE_AID" value="0xd2:0x76:0x00:0x01:0x24:0x01"/>
  <property name="APPLET_AID" value="0xd2:0x76:0x00:0x01:0x24:0x01:0x03:0x02:0xAF:0xAF:0x00:0x00:0x00:0x00:0x00:0x00"/>
  <property name="VERSION" value="1.0"/>
  <target name="init">
    <mkdir dir="${build}"/>
  </target>
  <target name="compile" depends="init" description="compile the source">
    <javac srcdir="${src}" destdir="${build}" includeantruntime="false" source="1.6" target="1.6">
      <classpath>
            <pathelement path="${JAVACARD_HOME}/lib/api_classic.jar"/>
      </classpath>
    </javac>
  </target>
  <target depends="compile" name="convert" description="convert to .cap">
      <java classname="com.sun.javacard.converter.Main" fork="true" failonerror="true">
      <arg line="-classdir ${build}"/>
      <arg line="-verbose"/>
      <arg line="-exportpath ${JAVACARD_HOME}/api_export_files"/>
      <arg line="-out CAP JCA EXP"/>
      <arg line="-applet ${APPLET_AID} ${APPLET_NAME}"/>
      <arg line="${JAVA_PACKAGE} ${PACKAGE_AID} ${VERSION}"/>
      <classpath>
            <pathelement location="${JAVACARD_HOME}/lib/tools.jar"/>
      </classpath>
    </java>
  </target>
  <target name="clean" description="clean up">
    <delete dir="${build}"/>
  </target>
</project>
