<project xmlns:ivy="antlib:org.apache.ivy.ant" name="aws-sdk-java-tests" default="run">
    <property name="ivy.install.version" value="2.5.0" />
    <condition property="ivy.home" value="${env.IVY_HOME}">
      <isset property="env.IVY_HOME" />
    </condition>
    <property name="ivy.home" value="${user.home}/.ant" />
    <property name="ivy.jar.dir" value="${ivy.home}/lib" />
    <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />

    <target name="download-ivy" unless="offline">
        <mkdir dir="${ivy.jar.dir}"/>
        <get src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
             dest="${ivy.jar.file}" usetimestamp="true"/>
    </target>

    <target name="init-ivy" depends="download-ivy">
        <path id="ivy.lib.path">
            <fileset dir="${ivy.jar.dir}" includes="*.jar"/>

        </path>
        <taskdef resource="org/apache/ivy/ant/antlib.xml"
                 uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
    </target>
    <target name="resolve" description="--> retrieve dependencies with ivy">
        <ivy:retrieve />
    </target>

    <target name="clean">
        <delete dir="build"/>
    </target>

    <path id="aws-s3-sdk-deps">
        <fileset dir="lib">
            <include name="*.jar"/>
        </fileset>
    </path>

    <target name="compile">
        <mkdir dir="build/classes"/>
        <javac srcdir="src" destdir="build/classes">
            <classpath refid="aws-s3-sdk-deps" />
        </javac>
    </target>

    <target name="jar">
        <mkdir dir="build/jar"/>
        <jar destfile="build/jar/FunctionalTests.jar" basedir="build/classes">
	    <archives>
	        <zips>
	            <fileset dir="lib/" includes="*.jar"/>
	         </zips>
	    </archives>
            <manifest>
                <attribute name="Main-Class" value="io.minio.awssdk.tests.FunctionalTests"/>
            </manifest>
        </jar>
    </target>
</project>
