<project name="keycloak-dist" basedir=".">
    <target name="wildfly">
        <unzip src="${org.wildfly:wildfly-dist:zip}" dest="${project.build.directory}"/>
        <chmod perm="755">
            <fileset dir="${project.build.directory}/wildfly-${wildfly.version}/bin">
                <include name="**/*.sh"/>
            </fileset>
        </chmod>
        <move todir="${build.target.dir}" overwrite="true">
            <fileset dir="${project.build.directory}/wildfly-${wildfly.version}">
                <include name="**/*"/>
            </fileset>
        </move>
        <delete dir="${project.build.directory}/wildfly-${wildfly.version}"/>
    </target>

    <!--    
    <target name="resteasy-modules">
        <get src="http://sourceforge.net/projects/resteasy/files/Resteasy%20JAX-RS/${resteasy.version}/resteasy-jaxrs-${resteasy.version}-all.zip"
             dest="${project.build.directory}" skipexisting="true"/>
        <unzip src="${project.build.directory}/resteasy-jaxrs-${resteasy.version}-all.zip"
               dest="${project.build.directory}">
            <patternset>
                <include name="resteasy-jaxrs-${resteasy.version}/resteasy-jboss-modules-${resteasy.version}.zip"/>
            </patternset>
            <mapper type="flatten"/>
        </unzip>
        <unzip src="${project.build.directory}/resteasy-jboss-modules-${resteasy.version}.zip"
               dest="${build.target.dir}/modules"/>
    </target>
    -->

    <target name="keycloak-server">
        <copy file="${org.keycloak:keycloak-server:war}"
              tofile="${build.target.dir}/standalone/deployments/auth-server.war" overwrite="true"/>
    </target>

    <target name="all" depends="wildfly, keycloak-server"/>
</project>
