【问题标题】:gradle uses its own dependency instead of build.gradle for commons-cligradle 使用自己的依赖而不是 build.gradle for commons-cli
【发布时间】:2015-10-07 15:44:32
【问题描述】:

我的项目无法编译,因为我已将 build.gradle 配置为使用 commons-cli-1.3,而 gradle 使用 commons-cli-1.2:

compile 'commons-cli:commons-cli:1.3'

如果我做依赖洞察正确地显示了我的期望:

commons-cli:commons-cli:1.3
\--- compile

但是,如果我检查 configurations.compile.asPath,我会在 commons-cli-1.3.jar 之前的路径上看到 lib/plugins/commons-cli-1.2.jar!

这似乎是因为我对具有编译依赖项 gradleApi() 的项目有项目依赖项 - 该项目使用 1.2.jar(dependencyInsight 中未报告)

我至少在 gradle 2.3 和 2.7 中看到了这种情况。

有人遇到这个问题并有解决方案吗? 对 gradle 而言,这似乎是非常垃圾和不透明的行为

【问题讨论】:

标签: java gradle


【解决方案1】:

所以,就我而言,这就是我为解决它所做的事情...... 我没有在我的其他项目依赖项中使用 gradleApi() ,而是明确添加了这些:

compile 'org.gradle:gradle-core:2.6'
compile 'org.codehaus.groovy:groovy-all:2.4.5'

即使这没有解决我的问题(它确实解决了),这确实使这些依赖项更容易查看/管理,例如添加 {exclude:} 子句等。我猜 gradleApi() 只是一个可怕的“便利”功能(参见长期存在的错误:https://issues.gradle.org/browse/GRADLE-1715)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-31
    • 2018-01-09
    • 2020-07-02
    • 2012-03-30
    • 2015-09-13
    • 2020-07-13
    • 2016-04-30
    • 1970-01-01
    相关资源
    最近更新 更多