<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright (c) 2005, 2010 IBM Corporation and others.

    This program and the accompanying materials
    are made available under the terms of the Eclipse Public License 2.0
    which accompanies this distribution, and is available at
    https://www.eclipse.org/legal/epl-2.0/

    SPDX-License-Identifier: EPL-2.0
   
    Contributors:
        IBM Corporation - initial API and implementation
 -->

<project name="Build Processor Jar" default="build" basedir="..">

	<target name="build" description="Cleans, builds and refreshes" depends="clean, lib/apttestprocessors.jar"/>

	<target name="init" depends="properties">
		<property name="temp.folder" value="${basedir}/temp.folder"/>
		<property name="build.result.folder" value="${basedir}"/>
	</target>

	<target name="properties" if="eclipse.running">
		<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
	</target>
			
	<target name="lib/apttestprocessors.jar" description= "Creates the lib/apttestprocessors.jar" depends="init">
		<property name="destdir" value="${temp.folder}/lib/apitooling-ant.bin"/>
		<delete dir="${destdir}"/>
		<mkdir dir="${destdir}"/>
		<mkdir dir="${build.result.folder}/lib"/>
		<!-- compile the source code -->
		<javac target="1.6" source="1.6" destdir="${destdir}" failonerror="false" verbose="false" debug="on">
			<src path="processors/"/>
			<compilerarg line="-proc:none" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/>
		</javac>
		<copy todir="${destdir}" failonerror="true" overwrite="false">
			<fileset dir="processors/">
				<exclude name="**/*.java"/>
				<exclude name="**/package.htm*"/>
			</fileset>
		</copy>
		<jar destfile="${build.result.folder}/lib/apttestprocessors.jar" basedir="${destdir}"/>
		<delete dir="${temp.folder}"/>
	</target>

	<target name="clean" description="Deletes previous build remnants" depends="init">
		<delete file="${build.result.folder}/lib/apttestprocessors.jar"/>
		<delete dir="${temp.folder}"/>
	</target>
</project>
