gpt4 book ai didi

java - 如何在 Gradle 中正确设置额外属性?

转载 作者:行者123 更新时间:2023-11-30 01:41:48 24 4
gpt4 key购买 nike

在我的顶级 build.gradle 项目中,我尝试使用以下方法添加 extra properties:

project.ext.libraries = [

junit: 'junit:junit:4.10'

]

然后我尝试在较低级别的 build.gradle 中引用它们,但出现此错误:

testCompile([
project.libraries.junit
])

但是我得到这个错误:

"Could not find property "libraries" for project

我是否需要向我的 Gradle 代码中添加任何其他内容才能使其正常工作?

最佳答案

假设您已经在根级 build.gradle 中使用 include 在根级 settings.gradle 中正确设置子项目关系

ext.libraries = [junit: 'junit:junit:4.10']

在你的子项目中:

dependencies{
testCompile libraries.junit
}

在您的根项目中定义的所有 ext 属性都可以在子项目中使用。

关于java - 如何在 Gradle 中正确设置额外属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34398752/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com