【问题标题】:Unable to find snapshot dependencies after gradle upgrade from 1.12 to 2.14从 1.12 升级到 2.14 后无法找到快照依赖项
【发布时间】:2016-10-26 12:24:45
【问题描述】:

gradle1.12 升级到2.14 后,maven 存储库中依赖项的快照版本无法识别。存储库设置正确,maven-metadata.xml 和依赖项存在,它使用 1.xx 版本的 gradle 构建。也无法从 2.xxx 的 gradle 发行说明中找到任何内容。有没有人遇到过这种情况? 以下是我的 build.gradle 文件。

// Apply the java plugin to add support for Java
apply plugin: 'java'

// In this section you declare where to find the dependencies of your project
repositories {
// Use 'maven central' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
mavenCentral()
 maven {
    name = 'Public'
    credentials {
        username = 'abc'
        password = 'abc'
    }
    url 'http://mydomain/nexus/content/groups/public/'
}

}

// In this section you declare the dependencies for your production and test   code
dependencies {
// The production code uses the SLF4J logging API at compile time
compile( 

[group: 'com.test.comp', name: 'comp-app-interface', version: "3.0.9_SNAPSHOT"],
[group: 'com.test.comp', name: 'comp-app-common', version: "3.0.10_SNAPSHOT", classifier: 'lib'],
)
// Declare the dependency for your favourite test framework you want to use in your tests.
// TestNG is also supported by the Gradle Test task. Just change the
// testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add
// 'test.useTestNG()' to your build script.
testCompile "junit:junit:4.11"
}

以下是我在使用 gradle 2.14 构建时收到的错误消息:

FAILURE: Build failed with an exception.

\* What went wrong:
Could not resolve all dependencies for configuration ':COMP-Testing-  Common:compileClasspath'.

\> Could not find com.test.comp:comp-app-common:3.0.10_SNAPSHOT.
 Searched in the following locations:
  file:/C:/Users/myname/.m2/repository/com/test/comp/comp-app-common/3.0.10_SNAPSHOT/comp-app-common-3.0.10_SNAPSHOT.pom
  file:/C:/Users/myname/.m2/repository/com/test/comp/comp-app-common/3.0.10_SNAPSHOT/comp-app-common-3.0.10_SNAPSHOT-lib.jar
  http://example.com/nexus/content/groups/public/com/test/comp/comp-app-common/3.0.10_SNAPSHOT/comp-app-common-3.0.10_SNAPSHOT.pom
  http://example.com/nexus/content/groups/public/com/test/comp/comp-app-common/3.0.10_SNAPSHOT/comp-app-common-3.0.10_SNAPSHOT-lib.jar
  Required by:
  com.test.comp:COMP-Testing-Common:3.0.10

但是当使用 gradle 1.12 构建时,它会下载正确的快照。

【问题讨论】:

    标签: maven gradle dependencies repository snapshot


    【解决方案1】:

    我发现并解决了这个问题。 由于版本号的格式,Gradle 无法识别它们是快照。 例如:当版本号和“快照”之间有下划线时,3.0.9_SNAPSHOT gradle 只是查找与该版本的依赖关系。但是如果中间有破折号而不是下划线(即3.0.9-SNAPSHOT),gradle 将读取maven-metadata.xml 并找到最新的快照。 使用 gradle 1.xxx 版本时,下划线工作正常。

    【讨论】:

      【解决方案2】:

      该错误表示所需的依赖项com.test.comp:comp-app-common:3.0.10_SNAPSHOT 不在任何指定的存储库中。请首先检查 gradle 是否正确(通过查看给定的存储库)。

      要更正错误,请检查是否包含所有相关存储库。如果错误仍然存​​在,请删除本地 Maven 存储库和 Gradle 缓存,然后重试。

      【讨论】:

        猜你喜欢
        • 2014-12-25
        • 2023-03-15
        • 1970-01-01
        • 2023-04-11
        • 1970-01-01
        • 2020-10-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多