The key fact seems to be that 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. If I switch the order of the repositories in the buildscript block to B then A, and clear the gradle cache by deleting the directories, the build will succeed.
Here is a walk-through of a simplified demonstration. I switched to the official M8 build and reproduced the same behavior. In the demo project below, there are no actual dependencies on Spring 3.1.0 in the build script or in my source code; I just picked a common library as an example.
This set of steps consistently fails:
-
Clear gradle cache by deleting C:\Users\dstine.gradle\caches\artifacts-8 and C:\Users\dstine.gradle\caches\1.0-milestone-8.
-
Execute “gradle clean build” with the following build.gradle:
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'
}
This set of steps consistently succeeds:
-
Clear gradle cache by deleting C:\Users\dstine.gradle\caches\artifacts-8 and C:\Users\dstine.gradle\caches\1.0-milestone-8.
-
Execute “gradle clean build” with the following build.gradle:
apply plugin: 'java'
buildscript {
repositories {
maven { url "http://repo1.maven.org/maven2" }
maven { url "http://repository.springsource.com/maven/bundles/release" }
}
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'
}
Other information:
If I substitute mavenCentral() for maven { url “http://repo1.maven.org/maven2” }, the failure case becomes successful.
If I run “gradle --refresh dependencies clean build --info” the failure case still fails. This is the output:
Starting Build
Settings evaluated using empty settings file.
Projects loaded. Root project using build file 'C:\RUP\workspaces\test\local\build.gradle'.
Included projects: [root project 'local']
Evaluating root project 'local' using build file 'C:\RUP\workspaces\test\local\build.gradle'.
Compiling build file 'C:\RUP\workspaces\test\local\build.gradle' using BuildScriptClasspathScriptTransformer.
file or directory 'C:\Users\dstine\.gradle\caches\artifacts-8\filestore', not found
Checksum SHA-1 unavailable. [HTTP GET: http://repository.springsource.com/maven/bundles/release/org/springframework/spring-core/3.1.0.RELEASE/spring-core-3.1.0.RELEASE.pom.sha1]
Resource missing. [HTTP GET: http://repository.springsource.com/maven/bundles/release/org/springframework/spring-core/3.1.0.RELEASE/spring-core-3.1.0.RELEASE.pom]
Resource missing. [HTTP HEAD: http://repository.springsource.com/maven/bundles/release/org/springframework/spring-core/3.1.0.RELEASE/spring-core-3.1.0.RELEASE.jar]
file or directory 'C:\Users\dstine\.gradle\caches\artifacts-8\filestore', not found
Checksum SHA-1 matched cached resource: [HTTP GET: http://repo1.maven.org/maven2/org/springframework/spring-core/3.1.0.RELEASE/spring-core-3.1.0.RELEASE.pom.sha1]
Checksum SHA-1 unavailable. [HTTP GET: http://repository.springsource.com/maven/bundles/release/org/springframework/spring-parent/3.1.0.RELEASE/spring-parent-3.1.0.RELEASE.pom.sha1]
Resource missing. [HTTP GET: http://repository.springsource.com/maven/bundles/release/org/springframework/spring-parent/3.1.0.RELEASE/spring-parent-3.1.0.RELEASE.pom]
Resource missing. [HTTP HEAD: http://repository.springsource.com/maven/bundles/release/org/springframework/spring-parent/3.1.0.RELEASE/spring-parent-3.1.0.RELEASE.jar]
Checksum SHA-1 matched cached resource: [HTTP GET: http://repo1.maven.org/maven2/org/springframework/spring-parent/3.1.0.RELEASE/spring-parent-3.1.0.RELEASE.pom.sha1]
Resource missing. [HTTP HEAD: http://repo1.maven.org/maven2/org/springframework/spring-parent/3.1.0.RELEASE/spring-parent-3.1.0.RELEASE.jar]
Checksum SHA-1 unavailable. [HTTP GET: http://repository.springsource.com/maven/bundles/release/org/springframework/spring-asm/3.1.0.RELEASE/spring-asm-3.1.0.RELEASE.pom.sha1]
Resource missing. [HTTP GET: http://repository.springsource.com/maven/bundles/release/org/springframework/spring-asm/3.1.0.RELEASE/spring-asm-3.1.0.RELEASE.pom]
Resource missing. [HTTP HEAD: http://repository.springsource.com/maven/bundles/release/org/springframework/spring-asm/3.1.0.RELEASE/spring-asm-3.1.0.RELEASE.jar]
Checksum SHA-1 matched cached resource: [HTTP GET: http://repo1.maven.org/maven2/org/springframework/spring-asm/3.1.0.RELEASE/spring-asm-3.1.0.RELEASE.pom.sha1]
Checksum SHA-1 unavailable. [HTTP GET: http://repository.springsource.com/maven/bundles/release/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom.sha1]
Resource missing. [HTTP GET: http://repository.springsource.com/maven/bundles/release/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom]
Resource missing. [HTTP HEAD: http://repository.springsource.com/maven/bundles/release/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar]
Checksum SHA-1 matched cached resource: [HTTP GET: http://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom.sha1]
Checksum SHA-1 unavailable. [HTTP GET: http://repository.springsource.com/maven/bundles/release/org/apache/commons/commons-parent/5/commons-parent-5.pom.sha1]
Resource missing. [HTTP GET: http://repository.springsource.com/maven/bundles/release/org/apache/commons/commons-parent/5/commons-parent-5.pom]
Resource missing. [HTTP HEAD: http://repository.springsource.com/maven/bundles/release/org/apache/commons/commons-parent/5/commons-parent-5.jar]
Checksum SHA-1 matched cached resource: [HTTP GET: http://repo1.maven.org/maven2/org/apache/commons/commons-parent/5/commons-parent-5.pom.sha1]
Checksum SHA-1 unavailable. [HTTP GET: http://repository.springsource.com/maven/bundles/release/org/apache/apache/4/apache-4.pom.sha1]
Resource missing. [HTTP GET: http://repository.springsource.com/maven/bundles/release/org/apache/apache/4/apache-4.pom]
Resource missing. [HTTP HEAD: http://repository.springsource.com/maven/bundles/release/org/apache/apache/4/apache-4.jar]
Checksum SHA-1 did not match cached resources: [HTTP GET: http://repo1.maven.org/maven2/org/apache/apache/4/apache-4.pom.sha1]
Resource found. [HTTP GET: http://repo1.maven.org/maven2/org/apache/apache/4/apache-4.pom]
Download http://repo1.maven.org/maven2/org/apache/apache/4/apache-4.pom
Resource missing. [HTTP HEAD: http://repo1.maven.org/maven2/org/apache/apache/4/apache-4.jar]
Resource missing. [HTTP HEAD: http://repo1.maven.org/maven2/org/apache/commons/commons-parent/5/commons-parent-5.jar]
Checksum SHA-1 matched cached resource: [HTTP GET: http://repo1.maven.org/maven2/org/springframework/spring-core/3.1.0.RELEASE/spring-core-3.1.0.RELEASE.jar.sha1]
downloading CachedResource: C:\Users\dstine\.gradle\caches\artifacts-7\artifacts7bdfe3021e729aece151fb2788d0956\org.springframework\spring-core.1.0.RELEASE\jar\spring-core-3.1.0.RELEASE.jar for http://repo1.maven.org/maven2/org/springframework/spring-core/3.1.0.RELEASE/spring-core-3.1.0.RELEASE.jar ...
[SUCCESSFUL ] org.springframework#spring-core;3.1.0.RELEASE!spring-core.jar (231ms)
Checksum SHA-1 matched cached resource: [HTTP GET: http://repo1.maven.org/maven2/org/springframework/spring-asm/3.1.0.RELEASE/spring-asm-3.1.0.RELEASE.jar.sha1]
downloading CachedResource: C:\Users\dstine\.gradle\caches\artifacts-7\artifacts7bdfe3021e729aece151fb2788d0956\org.springframework\spring-asm.1.0.RELEASE\jar\spring-asm-3.1.0.RELEASE.jar for http://repo1.maven.org/maven2/org/springframework/spring-asm/3.1.0.RELEASE/spring-asm-3.1.0.RELEASE.jar ...
[SUCCESSFUL ] org.springframework#spring-asm;3.1.0.RELEASE!spring-asm.jar (230ms)
Checksum SHA-1 matched cached resource: [HTTP GET: http://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar.sha1]
downloading CachedResource: C:\Users\dstine\.gradle\caches\artifacts-7\artifacts2e713c4c9d754c535205def24a7cb6a\commons-logging\commons-logging.1.1\jar\commons-logging-1.1.1.jar for http://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar ...
[SUCCESSFUL ] commons-logging#commons-logging;1.1.1!commons-logging.jar (246ms)
Compiling build file 'C:\RUP\workspaces\test\local\build.gradle' using BuildScriptTransformer.
All projects evaluated.
Selected primary tasks 'clean', 'build'
Tasks to be executed: [task ':clean', task ':compileJava', task ':processResources', task ':classes', task ':jar', task ':assemble', task ':compileTestJava', task ':processTestResources', task ':testClasses', task ':test', task ':check', task ':build']
:clean
Task ':clean' has not declared any outputs, assuming that it is out-of-date.
:clean UP-TO-DATE
:compileJava
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
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
BUILD FAILED
Total time: 6.382 secs
My environment for all executions in this reply:
------------------------------------------------------------
Gradle 1.0-milestone-8
------------------------------------------------------------
Gradle build time: Monday, February 13, 2012 11:53:32 PM UTC
Groovy: 1.8.4
Ant: Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Ivy: 2.2.0
JVM: 1.7.0_01 (Oracle Corporation 21.1-b02)
OS: Windows 7 6.1 amd64