gpt4 book ai didi

gradle - 在gradle中将变量传递给systemProperty

转载 作者:行者123 更新时间:2023-12-03 04:04:07 24 4
gpt4 key购买 nike

我的gradle文件如下所示:

test {
systemProperty 'my.example.timeout.millis', '2500'
}

run {
systemProperty 'my.example.timeout.millis', '1500'
}

但是我想做些类似的事情:
timeOut = 'my.example.timeout.millis' 

test {
systemProperty timeOut, '2500'
}

run {
println timeOut //prints expected value
systemProperty timeOut, '1500'
}

由于某种原因,我无法以这种方式设置 systemPropertyprintln可以工作。怎么来的?

仅定义一次 systemProperty并且仍然能够在测试和运行任务中使用它的最佳方法是什么?

最佳答案

尝试:

project.ext.timeOut ='my.example.timeout.millis' 

test {
systemProperty timeOut, '2500'
}

run {
println timeOut //prints expected value
systemProperty timeOut, '1500'
}

脚本中的属性应通过 ext实例的 project字段定义。

关于gradle - 在gradle中将变量传递给systemProperty,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32220746/

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