Gradle “如何覆盖配置级别”;及物性=false";对于一个依赖项

Gradle “如何覆盖配置级别”;及物性=false";对于一个依赖项,gradle,cucumber,build.gradle,Gradle,Cucumber,Build.gradle,我继承了一些代码,希望将cumber添加到项目中,最好尽量少做更改。但是gradle文件有一个配置级别的设置来阻止导入可传递的依赖项,这导致cucumberjava无法导入cucumber核心,因此失败 下面是build.gradle的相关部分: configurations.all { transitive = false } depdendencies { compile(group: .... lots of these testCompile(group: 'io.cuc

我继承了一些代码,希望将cumber添加到项目中,最好尽量少做更改。但是gradle文件有一个配置级别的设置来阻止导入可传递的依赖项,这导致cucumberjava无法导入cucumber核心,因此失败

下面是build.gradle的相关部分:

configurations.all {
  transitive = false
}

depdendencies {
  compile(group: .... lots of these

  testCompile(group: 'io.cucumber', name: 'cucumber-java8', version: '4.8.0', transitive: true)
  testCompile(group: 'io.cucumber', name: 'cucumber-testng', version: '4.8.0', transitive: true)
}
我的希望是,
transitive:true
将覆盖配置级别,但它不起作用

我还尝试添加:

configurations {
  all*.exclude group: 'io.cucumber', module: 'cucumber-java8'
}
但它根本就不会产生这种依赖性

我不希望手动提取cucumber的所有依赖项,也不希望删除此配置级别
transitive=false
。有可能做我正在尝试的事情吗?我可以只为
编译
依赖项设置配置吗?或者我必须删除配置级别设置并向每个编译依赖项添加
transitive:false


谢谢你的帮助

我想你正在寻找这样的东西:

configurations {
 compile {
    transitive false
  }
 testCompile {
    transitive true
  }
}

我想这就行了,谢谢!我早些时候尝试了一个稍微不同的格式,所以我认为它不起作用。实际上,我已经为testCompile设置了“transitive true”,这似乎有效,而不是将其设置为false,然后每次都重写它。我不想为每个配置设置“transitive false”,但现在只有5个左右,所以我想这会再次排序,谢谢