<?xml version="1.0" encoding="UTF-8"?>
<!--
	Copyright (c) 2012 Torkild U. Resheim and others.
	
	All rights reserved. This program and the accompanying materials
	are made available under the terms of the Eclipse Public License v1.0
	which accompanies this distribution, and is available at
	http://www.eclipse.org/legal/epl-v10.html
    
	Contributors:
		Torkild U. Resheim - initial API and implementation
-->
<project name="Download epubcheck" basedir="." default="all">

	<property name="epubcheck-version" value="3.0b5" />
	<property name="previous-version" value="3.0b4" />
	<property name="epubcheck-zip" value="epubcheck-${epubcheck-version}.zip" />
	<property name="epubcheck-dir" location="${basedir}/epubcheck/" />
	<property name="epubcheck-jar" location="${epubcheck-dir}/epubcheck-${epubcheck-version}.jar" />

	<available file="${epubcheck-jar}" type="file" property="epubcheck-present" />
	<available file="${epubcheck-dir}/epubcheck-${previous-version}.jar" property="clean-old" />

	<!--Remove older of EpubCheck if present -->
	<target name="clean" if="clean-old">
		<echo>Replacing old version of EpubCheck</echo>
		<delete>
			<fileset dir="${epubcheck-dir}">
				<include name="**/" />
			</fileset>
		</delete>
	</target>

	<target name="all" unless="epubcheck-present" depends="clean">
		<get src="http://epubcheck.googlecode.com/files/${epubcheck-zip}" dest="${epubcheck-zip}" skipexisting="true" verbose="true" retries="5" />
		<unzip src="${epubcheck-zip}" dest="${basedir}" />
		<move file="epubcheck-${epubcheck-version}" tofile="${epubcheck-dir}" />
		<delete file="${epubcheck-zip}" />
	</target>

</project>