Anonymous artifacts not working correctly when multiple are referenced in the same configuration


(Adam Elliott) #1

This is related to GRADLE-2899. I updated the related forum entry after the bug was fixed, so apologies if somebody’s already looking at this…

So with that fix in place, the original issue is solved in the nightbuild. But if it’s adjusted slightly it still fails:

Project a is the same as before, but in project b, add both of the artifacts from project a into the same configuration (before, they were in different ones):

dependencies {
    configB1 project(path:':a', configuration:'configA1')
    configB1 project(path:':a', configuration:'configA2')
}
task dumpConfig << {
    println configurations.configB1.files.join("\n")
}

It will only print out one of these jars, not both… this is working in 1.6, but not 1.7, 1.8, or 1.10-20131021220032+0000.

Following the note on the bug, I tried putting a baseName on the artifacts in ‘a’ and that works around the issue.


(Luke Daley) #2

HI Adam,

Could you provide a complete example that we can use to dig into this please?


(Adam Elliott) #3

Sure. Here’s an example that combines both issues:

settings.gradle:

include ':a'
include ':b'

project a:

configurations {
    configA1
    configA2
}
task A1jar(type: Jar) {
    archiveName = 'A1.jar'
    destinationDir = file("build/tmplibs")
}
task A2jar(type: Jar) {
    archiveName = 'A2.jar'
    destinationDir = file("build/tmplibs")
}
artifacts {
    configA1 A1jar
    configA2 A2jar
}

project b:

configurations {
    configB1
    configB2
}
dependencies {
    configB1 project(path:':a', configuration:'configA1')
    configB1 project(path:':a', configuration:'configA2')
    configB2 project(path:':a', configuration:'configA2')
}
task dumpConfig << {
    println "B1: " + configurations.configB1.files
    println "B2: " + configurations.configB2.files
}

In gradle 1.6, B1 contains A1 and A2, and B2 contains A2.

Thanks,

-Adam