Potential dependency resolving issue in Gradle 4.0

I tried upgrading our project from 3.4.1 to 4.0 and got a compilation error.

We have two separate sub-projects in our build that use different versions of the same 3rd party dependency.
If I understood it correctly, Gradle 4.0 does not respect the configuration and uses the more recent version of the two specified for both of the projects causing the said error.

For example:
sub-project A depends on X:Y:1.0
sub-project B depends on X:Y:1.5

With Gradle 4.0 it seems that X.Y.1.5 is used to compile both of the sub-projects.

I checked dependencies report and it looks identical for Gradle 3.4.1 and 4.0

The way Gradle selects a version shouldn’t have changed in 4.0. The ordering of dependencies may have changed. Gradle only selects the newest version when there are multiple versions available in the same configuration (e.g., for compilation).

Are you saying that subproject A is now seeing the wrong version of X:Y?

Do you have build scans you could share with the build failure? Or the output of the dependencies report for each subproject?

Turned out there is a transitive dependency on X:Y:1.5 in the sub-project that was failing with Gradle 4.0. I forced the dependency to X:Y:1.0 and it solved the problem.
It is not clear how compilation passed with Gradle 3.4.1, but since it is the older version it is probably not that important.

Was the subproject compiling against duplicate versions of X:Y with 3.4 but only a single version in 4.0?

Or could there be another dependency that has X:Y fatjared into it? In that case, compilation could change depending on the order of the dependencies.

The projects did not change and I don’t think it’s the case with fat jar as you are describing.