<project name="SIPRP" default="compile" basedir=".">
	<target name="init">
	<!-- directory definition -->
		<property name="src"			value="${basedir}"/>
		<property name="build"			value="${basedir}/build"/>
		<property name="dist"			value="${basedir}/../jars"/>
		<property environment="env"/>
		<condition property="etc" value="${env.SPEEDO_CONF}">
			<isset property="env.SPEEDO_CONF"/>
		</condition>
		<property name="etc"			value="${basedir}/../siprp"/>
		<property file="${etc}/speedo.properties"/>
		<fail unless="org.objectweb.speedo.mapperName"
			message="YOU MUST CONFIGURE THE FILE ${etc}/speedo.properties"/>
		<condition property="speedo.archive.exist">
			<available file="${dist}/speedo.jar"/>
		</condition>
		<fail unless="speedo.archive.exist"
			message="YOU MUST BUILD SPEEDO ARCHIVE in the speedo distribution by lauching the build.xml (Ant)"/>

		<!-- Building of a path which contains external jars -->
		<path id="classpath">
	        <pathelement location="${etc}"/>
		<pathelement location="${basedir}/../evutils"/>
		<pathelement location="${basedir}/../siprp"/>
		<pathelement location="${basedir}/../images"/>
	        <pathelement location="${build}"/>
			<fileset dir="${dist}">
				<include name="speedo.jar"/>
				<include name="jcalendar.jar"/>
				<include name="jxl.jar"/>
<!--				<include name="lib/log/log4j.jar"/> -->
				<include name="mysql*.jar"/>
				<include name="iText.jar"/>
			</fileset>
		</path>
	</target>



	<!-- ============================================================== -->
	<!-- ======================= Generation =========================== -->
	<!-- ============================================================== -->

	<target name="compile" depends="init">
        <mkdir dir="${build}"/>
        <javac srcdir="${src}" destdir="${build}" debug="on">
            <classpath refid="classpath"/>
            <include name="**/*.java"/>
        </javac>
		<taskdef name ="speedo"
	        classname="org.objectweb.speedo.ant.AntSpeedo"
	        classpathref="classpath" />
		<speedo confFile="${etc}/speedo.properties"
			output="${build}"
			src="${src}"
            classpathref="classpath"/>
   </target>


	<!-- ============================================================== -->
	<!-- ======================== Cleaning ============================ -->
	<!-- ============================================================== -->
	<target name="clean" depends="init">
		<delete dir="${build}"/>
	</target>


    <!-- ============================================================== -->
    <!-- =========================== Run ============================== -->
    <!-- ============================================================== -->
	<target name="createDataStruct" depends="init"
		description="Create the data structure for persistent classes">
		<property environment="env"/>
		<java classname="org.objectweb.speedo.tools.DataStructureCreation"
			fork="yes" classpathref="classpath">
			<arg line="siprp.data.Contacto siprp.data.Empresa siprp.data.Estabelecimento siprp.data.Trabalhador siprp.data.Aviso siprp.data.Marcacao siprp.data.MarcacaoEstabelecimento siprp.data.MarcacaoTrabalhador"/>
			<!--<arg line="siprp.data.Contacto invoice.Address invoice.Invoice invoice.Product invoice.ProductUnits"/>-->
		</java>
	</target>

    <target name="run" depends="init">
        <java classname="siprp.Main" fork="yes" classpathref="classpath">
            <sysproperty key="server.address"
                   value="ws_fpalma"
                   />
			<arg value="${etc}/speedo.properties"/>
        </java>
    </target>
</project>
