Uploaded image for project: 'Gradle'
  1. Gradle
  2. GRADLE-2100

Ordering of repository declarations can cause Could not resolve all dependencies error


    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: 1.0-milestone-8
    • Fix Version/s: 1.0-milestone-8a


      (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:

      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.

        Issue Links


          dstine Dan Stine added a comment -

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

          dstine Dan Stine added a comment - 1.0-milestone-8a fixes this issue for me.


            • Assignee:
              daz Daz DeBoer
              dstine Dan Stine
            • Votes:
              1 Vote for this issue
              2 Start watching this issue


              • Created: