Project dependencies to projects with the same name are processed incorrectly when setting the project group



In a multimodule project you can have multiple projects with the same name (but different path).
If one of these projects has a compile dependency to another one and both projects have the same group, then the project dependency is replaced with a reference to the wrong project.
This seems to be a bug in the Artifactresolving part.

Example project layout:

+--- frontend
\--- integration
     \--- frontend

:rootProject build.gradle:

task wrapper(type: Wrapper) {
  gradleVersion = '2.13'

:frontend build.gradle:

apply plugin: 'java'
group = ''

:integration:frontend build.gradle:

apply plugin: 'java'
group = ''
dependencies {
  compile project(':frontend')

When running gradlew :integration:frontend:dependencies the output shows the replacement of the project dependency:

compile - Dependencies for source set 'main'.
\--- project :frontend -> project :integration:frontend (*)

When removing one or both of the groups it works as expected. If the groups are not equal this also works as expected.
The expected output looks like this:

compile - Dependencies for source set 'main'.
\--- project :frontend

Here is a zip version of this example project (53.1 KB)