[GRADLE-2100] Ordering of repository declarations can cause Could not resolve all dependencies error Created: 14/Feb/12  Updated: 04/Jan/13  Resolved: 16/Feb/12

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-8
Fix Version/s: 1.0-milestone-8a

Type: Bug
Reporter: Dan Stine Assignee: Daz DeBoer
Resolution: Fixed Votes: 1

Issue Links:
Supercedes
Superceded by GRADLE-2101 Dependency resolution incorrectly use... Resolved

 Description   

(See forum post: http://forums.gradle.org/gradle/topics/could_not_resolve_all_dependencies_error_with_m8)

Suppose I have a buildscript block that declares two repositories A and B (in that order), and then a standard repositories block that declares only repository B. And suppose that both the buildscript block and the standard dependencies block declare the same dependency.

apply plugin: 'java'

buildscript {
    repositories {
        maven { url "http://repository.springsource.com/maven/bundles/release" }
        maven { url "http://repo1.maven.org/maven2" }
    }
    dependencies {
        classpath 'org.springframework:spring-core:3.1.0.RELEASE'
    }
}

repositories {
    maven { url "http://repo1.maven.org/maven2" }
}

dependencies {
    compile 'org.springframework:spring-core:3.1.0.RELEASE'
}

If I manually clear the cache by deleting ~/.gradle/caches/{1.0-milestone-8,artifacts-8) and then run "gradle clean build", I will get the following error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> Could not find group:org.springframework, module:spring-core, version:3.1.0.RELEASE.
  Required by:
      :local:unspecified

Reversing the repository declarations in the buildscript block, manually clearing the cache, and re-running gradle results in a successful build.

If I use mavenCentral() instead of manually specifying the URL, there is no problem.

Per Daz on the forums:

It seems you have indeed exposed a fairly critical bug in dependency resolution: for some reason we're using the 'springsource' repository identifier in the second resolve, which causes us to use the cache entries for the incorrect repository. (The repository URL is correct, but the repository identifier is used to lookup entries in the cache).

Since the module is missing from the 'springsource' repository, it appears to be missing in the second resolve.



 Comments   
Comment by Dan Stine [ 21/Feb/12 ]

1.0-milestone-8a fixes this issue for me.

Generated at Wed Jun 30 12:12:48 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.