如何在gradle构建脚本中添加bash和shell脚本目录路径?
How to add the bash and shell script directory path in gradle build script?
我想在我的 build.gradle 脚本中添加包含 windows 和 linux 的多个脚本的目录路径。
目前我正在定义这样的任务并且它工作正常。
task initdb(type: Exec){
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
commandLine 'cmd', '/c', 'My_CONF\pgdb\initdb.cmd'
} else {
commandLine 'My_CONF/pgdb/initdb.sh'
}
}
但是我想把这个任务定义为-
task initdb(type: Exec){
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
commandLine 'cmd', '/c', 'initdb.cmd'
} else {
commandLine 'initdb.sh'
}
}
这些脚本还使用了 My_CONF\pgdb 目录中的另一个脚本。
您可以尝试使用 Exec
类型任务的 workingDir
属性,默认为构建脚本根目录。查看有关它的文档 here.
我想在我的 build.gradle 脚本中添加包含 windows 和 linux 的多个脚本的目录路径。 目前我正在定义这样的任务并且它工作正常。
task initdb(type: Exec){
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
commandLine 'cmd', '/c', 'My_CONF\pgdb\initdb.cmd'
} else {
commandLine 'My_CONF/pgdb/initdb.sh'
}
}
但是我想把这个任务定义为-
task initdb(type: Exec){
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
commandLine 'cmd', '/c', 'initdb.cmd'
} else {
commandLine 'initdb.sh'
}
}
这些脚本还使用了 My_CONF\pgdb 目录中的另一个脚本。
您可以尝试使用 Exec
类型任务的 workingDir
属性,默认为构建脚本根目录。查看有关它的文档 here.