[GRADLE-2678] Gradle may resolve project module dependencies wrongly Created: 12/Feb/13 Updated: 10/Feb/17 Resolved: 10/Feb/17 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 1.0, 1.1, 1.2, 1.3, 1.4 |
Fix Version/s: | None |
Type: | Bug | ||
Reporter: | Gradle Forums | Assignee: | Unassigned |
Resolution: | Won't Fix | Votes: | 0 |
Description |
I have a project with a structure like this /util the workbench/util has a single dependency to the upper level util like this: dependencies { 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? |
Comments |
Comment by Gradle Forums [ 12/Feb/13 ] |
I cannot reproduce this. Can you provide a minimal reproducible example? |
Comment by Gradle Forums [ 12/Feb/13 ] |
Hi Peter, I have created a very minimal example demonstrating the problem. Can I send you a zip file somehow through the forum? |
Comment by Gradle Forums [ 12/Feb/13 ] |
The forum doesn't support attachments. Best use an external service like [Gist]([1]https://gist.github.com/) or GitHub and post the link here. |
Comment by Gradle Forums [ 12/Feb/13 ] |
I have uploaded the example to my google drive. Please download the example here: [1]https://docs.google.com/file/d/0BxgX3... |
Comment by Gradle Forums [ 12/Feb/13 ] |
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. |
Comment by Gradle Forums [ 12/Feb/13 ] |
Thanks for the example. This is indeed a bug. Some ways to work around:
|
Comment by Peter Niederwieser [ 12/Feb/13 ] |
Here is what I found. When resolving a project dep, Gradle internally represents both the consuming and the producing project as a module (version), where the module's name is the project's name, and the module's group is the parent project's path (roughly speaking). However, once project.group is set, that is used for the module's group. If consuming and producing projects additionally have the same name, the same module version will be used for both of them, leading to troubles. To reproduce: settings.gradle: include 'util', 'workbench:util' // uncommenting next line solves the problem // project(":util").name = "foo" build.gradle: allprojects { group = "foo" // not setting a group, or setting different groups, solves the problem apply plugin: "java" } util/workbench/build.gradle:
dependencies{
compile project(":util")
}
task debug << {
configurations.compile.each { println it }
}
Run gradle debug from the top level and observe that the compile configuration contains the util/workbench Jar, not the util Jar. Tested with Gradle 1.0-1.4. |
Comment by Benjamin Muschko [ 15/Nov/16 ] |
As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub. We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to. Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:
We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle! |
Comment by Benjamin Muschko [ 10/Feb/17 ] |
Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved. |