Question about source dependencies scenario

Greetings, I would like to ask about source dependencies in Gradle.
Suppose I had three separate projects: A, B, and C.
As A depends on B with version 1.0 and on C with version 1.0, but C depends on B with version 1.1, dependency resolution will result in project B with version 1.1.
Imagine that I combine projects A and B under the same root project, so A now has a source dependency on B, but C still brings B with version 1.1. How does Gradle handle this scenario? Does it recognize that it is the same artifact? Does it consider it a higher version?
In the documentation, I was unable to find an explanation of this scenario.

Hello @matans

i am new to gradle but this what i found about version conflict

https://docs.gradle.org/current/userguide/dependency_resolution.html#sec:version-conflict

also check
https://docs.gradle.org/current/userguide/single_versions.html

https://docs.gradle.org/current/userguide/rich_versions.html
https://docs.gradle.org/current/userguide/dynamic_versions.html
https://docs.gradle.org/current/userguide/dependency_locking.html

hope those help and have a nice day :slight_smile:

It’s been a long time since I looked at such “circular” dependency trees, but last time I did I observed that Gradle does version conflict resolution the same regardless of whether the module is a local project or an external module. So if the local project had a lower version than the external module then the external module would be selected. If thy have the same version I’m not sure which one wins.

My personal opinion; this type of “circular” dependency tree is an indicator that the modules may not be well organized and could need some refactoring. It hints that there could be too much coupling between the separate modules and that they should all be in the same project, or at least parts of them.

1 Like

Where do you see a dependency circle @Chris_Dore?

A
 > B 1.0
 > C 1.0
    > B 1.1

Regarding the conflict resolution I think it is exactly the other way around.
Iirc source dependencies are the Git-management wrapper around a composite build.
So the source dependency feature makes sure the Git-project of the dependency is cloned and checked out properly and then includes the build to form a composite build.
An included build should always win, no matter which version is declared if I’m not completely mistaken.
So actually I think the source dependency will win and be used.
But I might be wrong. Just try it out and share the result here for others to learn. :slight_smile: