Gradle may resolve project module dependencies wrongly

I have a project with a structure like this

/util /workbench/util (and 100+ other modules)

the workbench/util has a single dependency to the upper level util like this:

    compile project(":util")

When I build this module, however, the compilation fails, with errors indicating that the dependent module cannot be found.

The compiler arguments look like this:

  [org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler] Compiler arguments: -d E:\code\trunk\stepx\workbench\util\build\classes\main -g -classpath E:\code\trunk\stepx\workbench\util\build\libs\util-1.0-SNAPSHOT.jar …  

Notice that the dependency to the util is resolved to the workbench/util module’s OWN artifact, instead of the upper level artifact!!

I have tried to invoke the command “gradle :util:assemble” when in the workbench/util sub-directory. It does build the root level util project, as should be suspected. I also generate IntelliJ Idea modules for the project. Here, the dependency is also OK.

Renaming one of the modules is not an option, as it is an existing project with 100+ live customers, and several live branches.

Is there a viable workaround for the time being, as I suspect the described behavior is a bug you will have to fix?

I cannot reproduce this. Can you provide a minimal reproducible example?

Hi Peter, I have created a very minimal example demonstrating the problem. Can I send you a zip file somehow through the forum?

The forum doesn’t support attachments. Best use an external service like Gist or GitHub and post the link here.

I have uploaded the example to my google drive. Please download the example here:

In my example, if you rename the upper level util project to ie utils, the code will compile. As it is now, the compilation fails.

Thanks for the example. This is indeed a bug. Some ways to work around:

  • Use different values for ‘’ for the consuming and producing projects. Note that this doesn’t mean that you need to rename any directories. Project names and directories can be configured independently in ‘settings.gradle’. (See ‘Settings’ in the Gradle Build Language Reference.) * Use different values for ‘’ for the consuming and producing projects, or don’t set ‘’ at all.

Thanks for the hints. I now set the group name explicitly in my subproject build.gradle files. That seems to do the trick!