我正在尝试使用gradle运行一个简单的ScalaTest类,但我一直从gradle获取此日志:
* What went wrong:
Could not resolve all dependencies for configuration ':testCompile'.
> Could not download artifact 'org.scala-lang:scala-library:2.10.3@jar'
> Artifact 'org.scala-lang:scala-library:2.10.3@jar' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
我有这些依赖项:
dependencies {
compile "io.spray:spray-client:1.2.0"
compile "org.scala-lang:scala-library:2.10.3"
compile "org.scalatest:scalatest_2.10:1.9.1"
}
如果我使用--stacktrace
选项运行任务,我会得到:
* Exception is:
org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':testCompile'.
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDep
endencyResolver.wrapException(ErrorHandlingArtifactDependencyResolver.java:51)
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDep
endencyResolver.access$000(ErrorHandlingArtifactDependencyResolver.java:29)
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDep
endencyResolver$ErrorHandlingResolvedConfiguration.getFiles(ErrorHandlingArtifac
tDependencyResolver.java:84)
基本上我正在使用默认的maven repositores:
repositories {
mavenLocal()
mavenCentral()
}
答案 0 :(得分:3)
Maven Central上没有scala-library
的2.10.3版本。我看到的最新内容是2.10.2-RC2
。这可能是问题所在。
mavenLocal()
。gradle clean build --refresh-dependencies
。~/.gradle
,然后重试。--info
,--debug
或--stacktrace
运行,并查找提示。 PS:ScalaTest通常采用testCompile
配置。
PPS:mavenLocal()
只应在与本地Maven构建交换工件时声明。它不会保存任何下载时间或任何东西。相反,它会使构建更慢,更不可重复。