【问题标题】:How to exclude dependency from compile but not from testCompile如何从编译而不是从 testCompile 中排除依赖项
【发布时间】:2014-04-29 12:43:40
【问题描述】:

我对旧版本的库 testX 有传递编译依赖。库 testX 不应该是编译依赖,而是 testCompile 依赖。更重要的是,我想依赖 testX 的新版本,而不是旧版本。

我有一个部分解决方案,它设置了正确的库版本,但它通过覆盖编译依赖项来工作。但是我在编译时留下了不需要的 textX。

compile group: 'x', name: 'testX', version 'new'

我尝试从编译中排除库 testX 并添加显式 testCompile 依赖项,但排除也会从 testCompile 中删除依赖项。

testCompile group: 'x', name: 'testX', version 'new'

configurations {
    compile.exclude group: 'x', module: 'X'
}

【问题讨论】:

  • 你解决了吗?我也面临同样的问题。

标签: gradle dependency-management


【解决方案1】:

您可以通过插入以下命令强制整个项目解析为特定版本。请记住,这也将强制传递依赖项在编译时解析为该版本:

configurations.all {
  resolutionStrategy {
    force 'x:testX:1.1.1'
  }
}

【讨论】:

    猜你喜欢
    • 2020-02-15
    • 1970-01-01
    • 2017-11-11
    • 1970-01-01
    • 1970-01-01
    • 2011-03-03
    • 2014-01-01
    • 2015-09-29
    • 1970-01-01
    相关资源
    最近更新 更多