<?xml version="1.0"?>

<project name="SDK Demo AMP Build File" default="package-amp" basedir=".">
	
    <property name="project.dir" value="."/>
    <property name="build.dir" value="${project.dir}/build"/>
    <property name="config.dir" value="${project.dir}/config"/>
    <property name="jar.file" value="${build.dir}/lib/alfresco-sdk-custom-service.jar"/>
    <property name="amp.file" value="${build.dir}/dist/alfresco-sdk-custom-service.amp"/>
	
    <target name="mkdirs">
        <mkdir dir="${build.dir}/dist" />
        <mkdir dir="${build.dir}/lib" />
    </target>
    
    <path id="class.path">
        <dirset dir="${build.dir}" />
        <fileset dir="../../lib/server" includes="**/*.jar"/>
    </path>

    <target name="compile">
        <mkdir dir="${build.dir}/classes" />
        <javac classpathref="class.path" srcdir="${project.dir}/source/java" destdir="${build.dir}/classes" />
    </target>
    
    <target name="package-jar" depends="compile">
        <jar destfile="${jar.file}" >
            <fileset dir="${build.dir}/classes" excludes="**/custom*,**/*Test*" includes="**/*.class" />
        </jar>
    </target>
	
    <target name="package-amp" depends="mkdirs, package-jar" description="Package the Module" >
        <zip destfile="${amp.file}" >
            <fileset dir="${project.dir}/build" includes="lib/*.jar" />
            <fileset dir="${project.dir}" includes="config/**/*.*" excludes="**/module.properties" />
            <fileset dir="${project.dir}/config/alfresco/module/sdkDemoAmp" includes="module.properties" />
        </zip>
    </target>

    <target name="update-war" depends="package-amp" description="Update the WAR file.  Set -Dwar.file=..." >
        <echo>Installing SDK Demo AMP into WAR</echo>
        <java dir="." fork="true" classname="org.alfresco.repo.module.tool.ModuleManagementTool">
            <classpath refid="class.path" />
            <arg line="install ${amp.file} ${war.file} -force -verbose"/>
        </java>
    </target>

</project>