<project name="org.wso2.carbon.grant.ntlm" default="jar" basedir=".">
	<property name="is.home" value="../../"/>
    <property name="token_url" value="http://localhost:8280/token"/>
    <property name="consumer_key" value=""/>
    <property name="consumer_secret" value=""/>
    <property name="version" value="2.1.0"/>
    <property name="class.dir" value="target/classes"/>
    <property name="jna.dir" value="./jna"/>

    <target name="help">
        <echo/>
    </target>

    <target name="run" depends="jar">
        <java classname="org.wso2.carbon.grant.ntlm.Main" classpathref="javac.classpath"
              fork="true">
	    <sysproperty key="carbon.home"  value="${is.home}"/>
            <arg value="-ch" />
            <arg value="${is.home}"/>
            <arg value="-url"/>
            <arg value="${token_url}"/>
	    <arg value="-key"/>
            <arg value="${consumer_key}"/>
            <arg value="-secret" />
            <arg value="${consumer_secret}"/>
        </java>
    </target>

<path id="jar.classpath" >
            <pathelement path="${class.dir}"/>
			<fileset dir="${is.home}/repository/components/plugins">
                <include name="*.jar"/>
            </fileset>
    </path>

    <target name="init">
        <mkdir dir="${class.dir}"/>
		<manifestclasspath property="tem.classpath" jarfile="pathing.jar">
			<classpath refid="jar.classpath"/>
		</manifestclasspath>
		<jar destfile="pathing.jar" basedir="target\classes">
			<manifest>
                <attribute name="Class-Path" value="${tem.classpath}"/>
			</manifest>
		</jar>
        <path id="javac.classpath">
            <pathelement path="${class.dir}"/>
            <pathelement path="pathing.jar"/>
	    <fileset dir="${jna.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>
