Dependency resolution to multiple configurations of the same project fails

I have discovered an issue in the gradle 2.5 and 2.6-RC2 with multi-project builds. Or perhaps is a feature. :slight_smile: Anyway, what works with gradle 2.3 and 2.4 does not work anymore with gradle 2.5+.

I have created a small project that can reproduce the issue. It consists of a root project with two-subprojects

root_project
-> core
-> petshop
settings.gradle

The root project has only the settings.gradle file:

include "core"
include "petshop" 

The core project has the following build.gradle:

apply plugin: 'java' 
configurations{
    cats
}
sourceSets {
    cats 
}
dependencies {
    catsCompile project(':core')
}
jar {
    archiveName = "animals.jar"
} 
task createCats(type: Jar) {
    from sourceSets.cats.output
    archiveName "cats.jar"
}
artifacts {
    cats createCats
}

The core sub-project produces two artifacts: the default animals.jar and the cats.jar from the cats configuration.

The petshop project build.gradle:

apply plugin: 'java'
dependencies {
    compile project(':core') // required animals.jar
    compile project(path: ':core', configuration: 'cats')  // required cats.jar
}   
jar {
    archiveName = "petshop.jar"
}

The petshop project requires for compilation both animals.jar and cats.jar. But it seems that gradle places just one of the dependencies in the class-path of the petshop project. Depending of the order of the dependencies, the build fails finding classes from the animal.jar or cats.jar.

I have attached the project here, as I could not upload it.

https://drive.google.com/open?id=0B1tz713sef-Ta1VtWnRteVV4RFU

Thanks @bool, we’re taking a look. I’ve raised GRADLE-3330

I’ve pushed a fix to master, which will make it into Gradle-2.7. We’re currently discussing whether we can back-port the fix in time for Gradle-2.6.