import static org.junit.Assert.*

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

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)

    def projectA = compile.resolvedConfiguration.firstLevelModuleDependencies.find { it.moduleName == 'projectA' }
    assertEquals('1.2', projectA.moduleVersion)

    def projectB = projectA.children.find { it.moduleName == 'projectB' }
    assertEquals('1.5', projectB.moduleVersion)
}