import org.gradle.util.GradleUtil
import org.gradle.api.artifacts.ResolverContainer

sillyexceptions = 'sillyexceptions'
repotest = 'repotest'

/*
 * gradle_sourceforge:
 * - repotest
 * -- repotest
 * --- 1.0
 * ---- repotest-1.0.pom (-> testdep-1.0)
 *
 * - repotest
 * -- classifier
 * --- 1.0
 * ---- classifier-1.0.pom (-> classifier-dep-1.0)
 * ---- classifier-1.0-jdk14.jar
 * ---- classifier-1.0-jdk15.jar
 *
 * - repotest
 * -- classifier-dep
 * --- 1.0
 * ---- classifier-dep-1.0.pom
 * ---- classifier-dep-1.0.jar
 *
 * gradle_sourceforge2
 * - repotest
 * -- repotest
 * --- 1.0
 * ---- repotest-1.0.jar
 *
 * - testdep
 * -- testdep
 * --- 1.0
 * ---- testdep-1.0.pom
 * ---- testdep-1.0.jar
 *
 * - testdep2
 * -- testdep2
 * --- 1.0
 * ---- testdep2-1.0.jar
 * ---- testdep2-1.0.pom
 *
 * - jaronly
 * -- jaronly
 * --- 1.0
 * ---- jaronly-1.0.jar
 *
 * Maven Repo:
 *
 * - sillyexceptions
 * -- sillyexceptions
 * --- 1.0.1
 * ---- sillyexceptions-1.0.1.jar
 * ---- sillyexceptions-1.0.1.pom
 *
 * Transitive Dependencies
 *
 * repotest -> testdep
 * testdep -> testdep2
 */

configurations {
    test
}

repositories {
    mavenRepo(urls: ['http://gradle.sourceforge.net/repository/', 'http://gradle.sourceforge.net/otherrepo/']).allownomd = false
    mavenRepo(urls: 'http://gradle.sourceforge.net/otherrepo/')
    mavenCentral()
}

dependencies {
    test "$sillyexceptions:$sillyexceptions:1.0.1@jar", "$repotest:$repotest:1.0", "$repotest:classifier:1.0:jdk15", "jaronly:jaronly:1.0"
}

task retrieve << {
    GradleUtil.deleteDir(buildDir)
    GradleUtil.deleteDir(new File(build.gradleUserHomeDir, "$ResolverContainer.DEFAULT_CACHE_DIR_NAME/$sillyexceptions"))
    GradleUtil.deleteDir(new File(build.gradleUserHomeDir, "$ResolverContainer.DEFAULT_CACHE_DIR_NAME/$repotest"))
    GradleUtil.deleteDir(new File(build.gradleUserHomeDir, "$ResolverContainer.DEFAULT_CACHE_DIR_NAME/testdep"))
    GradleUtil.deleteDir(new File(build.gradleUserHomeDir, "$ResolverContainer.DEFAULT_CACHE_DIR_NAME/testdep2"))
    GradleUtil.deleteDir(new File(build.gradleUserHomeDir, "$ResolverContainer.DEFAULT_CACHE_DIR_NAME/jaronly"))
    Set files = configurations.test.resolve()
    ant {
        files.each {
            copy(file: it, todir: buildDir)
        }
    }
}
