<project basedir=".." default="run" name="Node Manager">
    <target name="init">
        <property name="dir.lib" value="${basedir}/lib"/>
        <property name="dir.resources" value="${basedir}/resources"/>
    	<property name="dir.jars" value="${dir.resources}/jars"/>
    	<property name="sqltool.jar" value="${dir.lib}/sqltool.jar"/>
    	<property name="dir.cfg" value="${dir.resources}/conf"/>
        <property name="spring.config" value="elemental-presentation-springconfig.xml"/>
        <property name="dir.data" value="${basedir}/data/pres-data"/>
    	<property name="dir.hsqldb" value="${basedir}/data/hsqldb"/>
        <property name="spring.class" value="com.intracom.elemental.lct.aop.LCTSpringInjector"/>

        <path id="run.classpath">
            <fileset dir="${dir.lib}">
                <include name="*.jar" />
            </fileset>
        </path>
    </target>

	<target name="create-database"
			description="Create the database files from the beginning"
			depends="init">
		<delete dir="${dir.hsqldb}"/>
		<java jar="${sqltool.jar}" fork="yes" failonerror="true">
			<arg value="--inlineRc=url=jdbc:hsqldb:file:${dir.hsqldb}/nm-mib;shutdown=true,user=SA,password="/>
			<arg value="${dir.resources}/sql/nm-mib.sql"/>
		</java>
	</target>

    <target name="run" description="Run Node Manager" depends="create-database">
        <java classname="org.opensource.AppWrapper" fork="yes" inputstring="">
            <classpath>
                <path refid="run.classpath"/>
                <pathelement path="${dir.cfg}"/>
                <pathelement path="${java.class.path}"/>
            </classpath>

            <jvmarg value="-Dswing.defaultlaf=com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"/>

            <sysproperty key="SpringConfig" value="${spring.config}"/>
            <sysproperty key="SpringConfigClass" value="${spring.class}"/>
            <sysproperty key="DataDir" value="${dir.data}"/>
        	
        	<arg value="mode=nm"/>
        </java>
    </target>
</project>
