Dependency Resolution does not fail when missing dependency

When I declare a dependency in a version that does not exist and this version is not selected during the version resolution because of another higher version in the dependency tree, the resolution does not fail.
For example I have 2 libraries in my repository: lib1 with versions 1.0.0 and 1.1.0, and lib2 with version 1.0.0 which depends on lib1:1.0.0. In my project I declare the 2 dependencies lib1:x1.1.0 (the “x” is on purpose, my point is about mistakes in dependencies declaration) and lib2:1.0.0. So I get this dependency tree:

  • lib1:x1.1.0
  • lib2:1.0.0
    • lib1:1.0.0

Gradle resolves this with no error by selecting lib1:1.0.0 and lib2:1.0.0. If I understand correctly, this is normal according to the resolution strategy, and Gradle first selects the versions before trying to fetch them. But I am wondering if I can force Gradle to fail if a version does not exist. This case can happen when a user did a mistake in the dependency version (“x1.0.0” instead of “1.0.0”), the build does not fail even if the version does not exist so the user may not see the mistake easily.
Is there an option or a way to force the failure in this case?


I don’t think so.
As the version got ruled out by conflict resolution there is no reason for Gradle to ask any repositories for those versions, that would just be wasted time in 98.7 % of the cases and Gradle is pretty good in avoiding time-waste. :slight_smile:

ok, thanks for your answer. I totally get why it is not available.
Just for information, I was able to create a simple task to check that:

tasks.register("checkDeps") {
    doLast {
        configurations.getByName("implementation").getAllDependencies().forEach { dep -> 
            var config = configurations.create("config")
            var dependency = dependencies.create(dep.getGroup() + ":" + dep.getName() + ":" + dep.getVersion())