import static org.junit.Assert.*

configurations {
    compile
}
dependencies {
    repositories {
        add(new org.apache.ivy.plugins.resolver.FileSystemResolver()) {
            name = 'resolver'
            addArtifactPattern(projectDir.absolutePath + '/[module]-[revision].jar')
            addIvyPattern(projectDir.absolutePath + '/[module]-[revision]-ivy.xml')
        }
    }
    compile 'test:projectA:1.2'
}

file("projectA-1.2.jar").text = ''
file("projectB-1.5.jar").text = ''

defaultTasks 'listJars'

task listJars << {
    def compile = configurations.compile

    Set jars = compile.collect { it.name } as Set
    assertEquals(['projectA-1.2.jar', 'projectB-1.5.jar'] as Set, jars)

    Set artifacts = compile.resolvedConfiguration.resolvedArtifacts.collect {
        "${it.name}-${it.type}-${it.extension}" as String
    } as Set
    assertEquals(['projectA-jar-jar', 'projectB-jar-jar'] as Set, artifacts)

    Set modules = compile.resolvedConfiguration.resolvedArtifacts.collect {
        def dep = it.resolvedDependency
        "${dep.moduleGroup}-${dep.moduleName}-${dep.moduleVersion}" as String
    } as Set
    assertEquals(['test-projectA-1.2', 'test-projectB-1.5'] as Set, modules)
}