<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="XEMELIOS-batch" default="usage" basedir=".">
    <description>Builds, tests, and runs the project XEMELIOS xemelios-core</description>
    <property file="${user.home}/.ant.properties"/>
    <property name="compile.debug" value="true"/>
    <property file="build.properties"/>

    <target name="usage">
        <echo> Using ${ant.version} These are targets supported by this ANT build script: compile -
            compile all .java files, except thoses in ./tmp folder. clean - deletes all compiled and
            generated files and resources. jars - build jar files. Do not call this script directly,
            use the one located at root of projet (in ../..) instead. </echo>
    </target>

    <target name="compile" depends="mk-output-dirs">
        <javac srcdir="java" destdir="build/classes" debug="${compile.debug}" encoding="ISO-8859-1">
            <classpath>
                <!--fileset dir="lib" includes="*.jar"/-->
                <fileset dir="../starter/build/jars" includes="*.jar"/>
                <pathelement path="../xml-marshall/build/classes"/>
                <pathelement path="../core/build/classes"/>
                <pathelement path="../import-batch/build/classes"/>
                <pathelement path="../xemelios-core/build/classes"/>
                <pathelement path="../mysql-persistence/build/classes"/>
                <fileset dir="../core/lib/" includes="*.jar"/>
                <fileset dir="../xemelios-core/lib">
                     <include name="swing-worker.jar"/>
                     <include name="core-renderer.jar"/>
                     <include name="iText*.jar"/>
                </fileset>
            </classpath>
        </javac>
        <copy todir="build/classes">
            <fileset dir="java">
                <include name="**/*"/>
                <exclude name="**/*.java"/>
                <exclude name="**/CVS/*"/>
                <exclude name="**/*.form"/>
            </fileset>
        </copy>
    </target>

    <target name="jars">
        <property file="component.properties"/>
        <copy file="manifest/manifest.txt" tofile="build/manifest.txt">
            <filterset>
                <filter token="version" value="${component.release}"/>
                <filter token="name" value="${component.name}"/>
            </filterset>
        </copy>
        <jar destfile="build/jars/xemelios-batch.jar" basedir="build/classes"
            manifest="build/manifest.txt"/>
    </target>

    <target name="clean">
        <delete dir="build"/>
    </target>


    <target name="mk-output-dirs">
        <mkdir dir="build/classes"/>
        <mkdir dir="build/jars"/>
    </target>

    <!--target name="config" description="Genere l'arborescence de mise a jour">
		<property file="component.properties"/>
		<property name="component.dir" value="build/config/${component.name}/${component.release}"/>
		<mkdir dir="${component.dir}"/>
		<copy todir="${component.dir}">
                    <fileset dir="lib" includes="*.jar *.dll"/>
                    <fileset dir="build/jars" includes="*.jar"/>
                    <fileset dir="res" includes="*.*"/>
		</copy>
		<propertyfile file="${component.dir}/component.properties">
			<entry key="description" value="Programme Xemelios"/>
			<entry key="type" value="xemelios-updates"/>
			<entry key="base.dest" value="${xemelios.prg}/root/lib/"/>
			<entry key="deletes" value="${xemelios.prg}/root/documents-def/documents.xml,${xemelios.prg}/root/documents-def/etatPaye.xsl,${xemelios.prg}/root/documents-def/etatVersement.xsl,${xemelios.prg}/root/documents-def/nomenclature-import.xsl,${xemelios.prg}/root/documents-def/nomenclature-import-versement.xsl,${xemelios.prg}/root/documents-def/nomenclature-paye.xsl,${xemelios.prg}/root/documents-def/nomenclature-versement.xsl,${xemelios.prg}/root/documents-def/persistence-config/etatPaye-import-mysql.xsl,${xemelios.prg}/root/documents-def/persistence-config/etatVersement-import-mysql.xsl,${xemelios.prg}/root/documents-def/persistence-config/index.xsl,${xemelios.prg}/root/documents-def/persistence-config/paye-persistence.xml,${xemelios.prg}/root/documents-def/persistence-config/versement-persistence.xml,${xemelios.prg}/root/lib/import-batch.jar,${xemelios.prg}/root/lib/Xilize.jar,${xemelios.prg}/root/lib/cssparser-0-9-4-fs.jar,${xemelios.prg}/root/lib/looks-2.0.4.jar,${xemelios.prg}/root/lib/svgSalamander.jar,${xemelios.prg}/root/lib/itext-paulo-155.jar,${xemelios.prg}/root/setup-xemelios.zip,${xemelios.prg}/root/lib/commons-io-1.2.jar"/>
            <entry key="log4j.xml.dest" value="${xemelios.prg}/root"/>
            <entry key="modeleExcelHtml.xls.dest" value="${xemelios.prg}/root/resources"/>
            <entry key="modeleExportXemelios.xls.dest" value="${xemelios.prg}/root/resources"/>
            <entry key="modeleExportXemelios-97.xls.dest" value="${xemelios.prg}/root/resources"/>
            <entry key="modeleExportXemelios-97SR1.xls.dest" value="${xemelios.prg}/root/resources"/>
            <entry key="viewdoc.cmd.dest" value="${xemelios.prg}/root"/>
            <entry key="XMLPrettyPrint.xsl.dest" value="${xemelios.prg}/root/resources"/>
            <entry key="couri.ttf.dest" value="${xemelios.prg}/root/resources"/>
			<entry key="configuration" value="fr.gouv.finances.cp.xemelios.patches.Core33114"/>
			<entry key="requires" value="${component.requires}"/>
		</propertyfile>
    </target-->

    <target name="setup">
        <mkdir dir="build/setup"/>
        <mkdir dir="build/setup/bin"/>
        <mkdir dir="build/setup/lib"/>
        <mkdir dir="build/setup/conf"/>
        <mkdir dir="build/setup/logs"/>
        <mkdir dir="build/setup/resources"/>
        <mkdir dir="build/setup/documents-def"/>

        <copy todir="build/setup/lib">
            <!-- fileset dir="lib" includes="*.jar"/ -->
            <fileset dir="build/jars" includes="*.jar"/>
            <fileset dir="../core/build/jars" includes="*.jar"/>
            <fileset dir="../core/lib" includes="*.jar"/>
            <fileset dir="../import-batch/build/jars" includes="*.jar"/>
            <fileset dir="../mysql-persistence/build/jars" includes="*.jar"/>
            <fileset dir="../mysql-persistence/lib" includes="*.jar"/>
            <fileset dir="../xml-marshall/build/jars" includes="*.jar"/>
            <fileset dir="../xemelios-core/build/jars" includes="*.jar"/>
            <fileset dir="../xemelios-core/lib">
                <include name="swing-worker.jar"/>
                <include name="core-renderer.jar"/>
                <include name="iText*.jar"/>
                <include name="swing-layout-1.0.jar"/>
            </fileset>
            <fileset dir="../starter/build/jars" includes="xemelios.jar"/>
            <fileset dir="../auth-std-db/build/jars" includes="auth-std-db.jar"/>
            <fileset dir="../edmn/build/jars" includes="*.jar"/>
            <fileset dir="../cg-etat/build/jars" includes="*.jar"/>
        </copy>
        <copy todir="build/setup/conf">
            <!--fileset dir="conf">
                <include name="*"/>
                <exclude name="batch-conf.xml"/>
            </fileset-->
            <fileset dir="resources" includes="log4j*,*.properties"/>
        </copy>
        <copy todir="build/setup/bin">
            <fileset dir="resources" includes="*.sh,*.bat"/>
        </copy>
        <copy todir="build/setup/resources">
            <fileset dir="resources" includes="*.xls"/>
        </copy>
        <copy todir="build/setup/documents-def">
            <fileset dir="../carte-achat/conf" includes="**/*" excludes="**/CVS"/>
            <fileset dir="../cfg-paye/conf" includes="**/*" excludes="**/CVS"/>
            <fileset dir="../cg-colloc/conf" includes="**/*" excludes="**/CVS"/>
            <fileset dir="../edmn/conf" includes="**/*" excludes="**/CVS"/>
            <fileset dir="../ertn/conf" includes="**/*" excludes="**/CVS"/>
            <fileset dir="../erar/conf" includes="**/*" excludes="**/CVS"/>
            <fileset dir="../facture-depense/conf" includes="**/*" excludes="**/CVS"/>
            <fileset dir="../facture-recette/conf" includes="**/*" excludes="**/CVS"/>
            <fileset dir="../pes-aller/conf" includes="**/*" excludes="**/CVS"/>
            <fileset dir="../pes-facture/conf" includes="**/*" excludes="**/CVS"/>
            <fileset dir="../quittancement/conf" includes="**/*" excludes="**/CVS"/>
            <fileset dir="../rapport/conf" includes="**/*" excludes="**/CVS"/>
            <fileset dir="../versement/conf" includes="**/*" excludes="**/CVS"/>
            <fileset dir="../cg-etat/conf" includes="**/*" excludes="**/CVS"/>
        </copy>
        <xslt style="batch-conf-maker.xsl" in="conf/batch-conf.xml" out="build/setup/conf/batch-conf.xml"/>
        <fixcrlf file="build/setup/conf/batch-conf.xml" eol="dos"/>
        <zip destfile="build/xemelios-batches.zip" basedir="build/setup" compress="true"
            includes="**/*" level="9"/>
        <copy todir="../../build" file="build/xemelios-batches.zip"/>
    </target>
    <target name="setup-CdC" depends="setup">
        <delete file="build/xemelios-batches.zip"/>
        <delete file="build/setup/conf/mysql.properties"/>
        <delete file="build/setup/conf/batch-conf.xml"/>
        <xslt style="clients/CdC/batch-conf-maker.xsl" in="conf/batch-conf.xml" out="build/setup/conf/batch-conf.xml"/>
        <copy file="clients/CdC/mysql.properties" todir="build/setup/conf" overwrite="yes"/>
        <zip destfile="build/xemelios-batches.zip" basedir="build/setup" compress="true"
            includes="**/*" level="9"/>
        <copy todir="../../build" file="build/xemelios-batches.zip" overwrite="true"/>
    </target>

</project>
