<project name="org.wso2.carbon.registry.migration" default="jar" basedir=".">
    <property name="registry.home" value="/Path_To_AM_Pack_Location"/>
    <property name="username" value="xxxx"/>
    <property name="password" value="xxxx"/>
    <property name="host" value="localhost"/>
    <property name="port" value="9443"/>
    <property name="gateway_host" value="localhost"/>
    <property name="gateway_port" value="9443"/>
    <property name="version" value="1.4.0"/>
    <property name="class.dir" value="target/classes"/>
    
    <property name="dbUrl" value="Database jdbc url of the AM database"/>
    <property name="dbDriver" value="Database driver name of the AM database"/>
    <property name="sql.dir" value="/Path_To_JDBC_Driver_Location"/>
    <property name="dbUsername" value="xxxx"/>
    <property name="dbPassword" value="xxxx"/>

    <target name="help">
        <echo/>
    </target>  
    
  
    <target name="run" depends="jar">
        <java classname="org.wso2.carbon.registry.migration.Main" classpathref="javac.classpath"
              fork="true">
	    <sysproperty key="carbon.home"  value="${registry.home}"/>
            <arg value="-ch" />
            <arg value="${registry.home}"/>
            <arg value="-h"/>
            <arg value="${host}"/>
            <arg value="-p" />
            <arg value="${port}"/>
	    <arg value="-gh"/>
            <arg value="${gateway_host}"/>
            <arg value="-gp" />
            <arg value="${gateway_port}"/>
            <arg value="-u" />
            <arg value="${username}"/>
            <arg value="-pw" />
            <arg value="${password}"/>
	    <arg value="-durl" />
            <arg value="${dbUrl}"/>
            <arg value="-dr" />
            <arg value="${dbDriver}"/>
            <arg value="-du" />
            <arg value="${dbUsername}"/>
            <arg value="-dpw" />
            <arg value="${dbPassword}"/>
        </java>
    </target>

    <target name="init">
        <mkdir dir="${class.dir}"/>
        <path id="javac.classpath">
            <pathelement path="${class.dir}"/>
             <fileset dir="${registry.home}/repository/components/plugins">
                <include name="*.jar"/>
            </fileset>
	    <fileset dir="${sql.dir}">
                <include name="*.jar"/>
            </fileset>
        </path>        
    </target>
 
    <target name="compile" depends="init" description="Compile all Java">
        <javac srcdir="src" destdir="${class.dir}" debug="true">
            <classpath refid="javac.classpath"/>         
          
        </javac>
    </target>

    <target name="clean">
        <delete dir="target" quiet="true"/>
        <delete dir="${class.dir}" quiet="true"/>
    </target>

    <target name="jar" depends="clean, compile">
        <jar jarfile="target/${ant.project.name}-${version}.jar">
            <fileset dir="target/classes">
                <include name="**/*.class"/>
            </fileset>
        </jar>
        <copy file="target/${ant.project.name}-${version}.jar" todir="dist" overwrite="true" />
    </target>

 

</project>
