【发布时间】:2018-06-04 09:32:51
【问题描述】:
我正在尝试将 bat 和 sh 文件(取决于正在运行的操作系统)与 gradle exec 任务挂钩。但我无法弄清楚如何从 exec 任务向 bat/sh 发送参数。
task testing(type:Exec) {
workingDir '.'
if (System.properties['os.name'].toLowerCase().contains('windows')) {
if ( project.hasProperty("arg1") ) {
println arg1
args arg1
commandLine 'cmd', '/c', 'run.bat'
}else{
commandLine 'cmd', '/c', 'run.bat'
}
}else {
if ( project.hasProperty("arg1") ) {
args arg1
commandLine './run.sh'
}else{
commandLine './run.sh'
}
}
}
如果我以gradle testing -Parg1=test 运行此任务,在println arg1 中,它会打印测试
但是我如何将此测试作为参数传递给 bat/sh 文件。
【问题讨论】:
-
你想用 shell 文件实现什么?
标签: batch-file gradle sh build.gradle command-line-arguments