我想在我的测试中模仿依赖解决。我希望存储库将由 sup 项目的子项目继承。检查它
Project sup = ProjectBuilder.builder().build()
sup.repositories {mavenCentral()}
Project sub = ProjectBuilder.builder().withParent(sup).build()
sup.repositories {mavenCentral()} //just to be sure
sub.apply plugin: 'java'
sub.dependencies {compile 'com.google.guava:guava:14.0'}
sub.configurations.findByName('compile').resolvedConfiguration.rethrowFailure()
但它失败了
org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':test:compile'.
at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration.rethrowFailure(DefaultLenientConfiguration.java:52)
...
Caused by: org.gradle.api.internal.artifacts.ivyservice.ModuleVersionNotFoundException: Could not find group:com.google.guava, module:guava, version:14.0.
Required by:
test:test:unspecified
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.LazyDependencyToModuleResolver$StaticVersionResolveResult.notFound(LazyDependencyToModuleResolver.java:159)
...
我可以通过添加来修复它sub.repositories {mavenCentral()}
。但对我来说,没有它似乎应该可以工作。
我仍然使用 gradle 1.2