<project default="all-libs">

	<available file="lib/midpapi20.jar" property="midpapi.lib.exists"/>
	<available file="lib/bcel-5.2.jar" property="bcel.lib.exists"/>			
	<available file="lib/javacc.jar" property="javacc.lib.exists"/>			
	<available file="lib/proguard.jar" property="proguard.lib.exists"/>			
	<available file="lib/antenna-bin-1.2.0-beta.jar" property="antenna.lib.exists"/>			
	<available file="lib/junit.jar" property="junit.lib.exists"/>
	<available file="lib/cobertura.jar" property="cobertura.lib.exists"/>
	<available file="lib/microemulator.jar" property="microemulator.lib.exists"/>

	<macrodef name="download">
		<attribute name="zipname"/>
		<attribute name="jars" default="**/*.jar"/>
		<sequential>
			<mkdir dir="lib"/>
			<get src="http://luaj.sourceforge.net/lib/@{zipname}.tar.gz" 
				dest="lib/@{zipname}.tar.gz"/>
			<gunzip src="lib/@{zipname}.tar.gz" dest="lib/@{zipname}.tar"/>
			<untar src="lib/@{zipname}.tar" dest="lib" overwrite="true">
			    <patternset>
			        <include name="@{jars}"/>
			    </patternset>
			    <mapper type="flatten"/>
			</untar>
	   </sequential>
	</macrodef>

	<target name="wtk-libs" unless="midpapi.lib.exists">
		<download zipname="wtk-2.5.2-api"/>
	</target>
	<target name="bcel-lib" unless="bcel.lib.exists">
		<download zipname="/bcel-5.2"/>
	</target>
	<target name="javacc-lib" unless="javacc.lib.exists">
		<download zipname="javacc-5.0"/>
	</target>
	<target name="proguard-lib" unless="proguard.lib.exists">
		<download zipname="proguard4.6"/>
	</target>
	<target name="antenna-lib" unless="antenna.lib.exists">
		<download zipname="antenna-bin-1.2.0-beta"/>
	</target>
	<target name="junit-lib" unless="junit.lib.exists">
		<download zipname="junit-3.8.2"/>
	</target>
	<target name="cobertura-lib" unless="cobertura.lib.exists">
		<download zipname="cobertura-1.9.4.1-bin"/>
	</target>
	<target name="microemulator-lib" unless="microemulator.lib.exists">
		<download zipname="microemulator-2.0.4" jars="**/microemulator.jar"/>
	</target>

	<target name="all-libs" depends="wtk-libs,bcel-lib,javacc-lib,proguard-lib,antenna-lib,junit-lib,cobertura-lib"/>
	
</project>
