我们有一个公司范围内的Nexus 3服务器
开发人员使用两个存储库:
两个存储库都用于Gradle构建:
repositories {
maven {
name "snapshots"
url "http://nexus3.server:8081/repository/maven-snapshots"
}
maven {
name "releases"
url "http://nexus3.server:8081/repository/maven-releases"
}
}
现在当Gradle尝试解析快照依赖关系时,它会询问版本库,Nexus会回复
Error 400 Bad Request
Repository version policy: RELEASE does not allow version: 1.0-SNAPSHOT
并且构建失败并带有
> Could not resolve group.id:artifact-id:1.0-SNAPSHOT.
Required by:
:my-project:unspecified
> Could not resolve group.id:artifact-id:1.0-SNAPSHOT.
> Could not get resource 'http://nexus3.server:8081/repository/maven-releases/group/id/artifact-id/1.0-SNAPSHOT/artifact-id-1.0-SNAPSHOT.pom'.
> Could not GET 'http://nexus3.server:8081/repository/maven-releases/group/id/artifact-id/1.0-SNAPSHOT/artifact-id-1.0-SNAPSHOT.pom'. Received status code 400 from server: Bad Request
如何配置Gradle以便忽略此错误并尝试下一个存储库("快照")?或者是否可以将Nexus配置为返回404 Not Found而不是400 Bad Request?
版本:Gradle 2.9
答案 0 :(得分:2)
查看gradle usage的Nexus Repository Manager 3文档以及example projects。这应该向您展示如何使用init.gradle从存储库组下载。
答案 1 :(得分:2)
RaGe的评论是一个很好的提示:依赖既不在snapshots
也不在releases
,而是在我不知道的第三个存储库中。将第三个存储库添加到Gradle后,依赖项已解决。