<?xml version="1.0" encoding="UTF-8"?>
<project name="create-sample-capps" default="zip" basedir=".">

    <property name="project-name" value="${ant.project.name}"/>
    <property name="res-dir" value="src/main/resources"/>
    <property name="target-dir" value="target"/>
    <property name="jaggery-api-dir" value="src/main/jaggeryapi"/>
    <property name="portal-css-dir" value="src/main/portalcss"/>

    <property name="capp_common" value="src/main/capp/common"/>
    <property name="capp_dashboard" value="src/main/capp/dashboard"/>
    <property name="capp_offline" value="src/main/capp/offline"/>
    <property name="capp_realtime" value="src/main/capp/realtime"/>
    <property name="capp_artifacts_is" value="src/main/capp/artifacts_is"/>
    <property name="capp_artifacts_offline" value="src/main/capp/artifacts_offline"/>
    <property name="capp_artifacts_realtime" value="src/main/capp/artifacts_realtime"/>

    <property name="ANALYTICS_IS_capp" value="org_wso2_analytics_is-1.0.0"/>
    <property name="ANALYTICS_IS_capp_realtime" value="org_wso2_analytics_is_realtime-1.0.0"/>
    <property name="ANALYTICS_IS_capp_offline" value="org_wso2_analytics_is_offline-1.0.0"/>

    <target name="clean">
        <delete dir="${target-dir}"/>
    </target>

    <target name="pre-configure">
        <mkdir dir="${target-dir}"/>
        <copy file="${jaggery-api-dir}/isanalytics.jag" todir="${res-dir}"/>
        <copy file="${jaggery-api-dir}/issessionanalytics.jag" todir="${res-dir}"/>
        <copy file="${jaggery-api-dir}/isanalytics-common.jag" todir="${res-dir}"/>
        <copy file="${jaggery-api-dir}/isanalytics-alerts.jag" todir="${res-dir}"/>
        <copy file="${portal-css-dir}/custom.css" todir="${res-dir}"/>
    </target>

    <target name="zip" depends="clean,pre-configure">
        <zip destfile="${res-dir}/${ANALYTICS_IS_capp}.car">
            <zipfileset dir="${capp_common}"/>
            <zipfileset dir="${capp_dashboard}"/>
            <zipfileset dir="${capp_realtime}"/>
            <zipfileset dir="${capp_offline}"/>
            <zipfileset dir="${capp_artifacts_is}"/>
        </zip>
        <zip destfile="${res-dir}/${ANALYTICS_IS_capp_realtime}.car">
            <zipfileset dir="${capp_common}"/>
            <zipfileset dir="${capp_realtime}"/>
            <zipfileset dir="${capp_artifacts_realtime}"/>
        </zip>
        <zip destfile="${res-dir}/${ANALYTICS_IS_capp_offline}.car">
            <zipfileset dir="${capp_common}"/>
            <zipfileset dir="${capp_dashboard}"/>
            <zipfileset dir="${capp_offline}"/>
            <zipfileset dir="${capp_artifacts_offline}"/>
        </zip>
    </target>

</project>
