vips
(vipss78)
July 13, 2012, 8:32pm
1
Can not execute the following task
exec {
commandLine ‘source’
args “/home/user/mySource”
} I was expecting it to do similar to
source /home/user/mySource pr
. /home/user/mySource
but for both the operation it throws the following exception
Caused by: java.io.IOException: Cannot run program “source” (in directory “/home/vbharakhada/sandbox/b-pubmind/srcroot/pubmindApp”): java.io.IOException: error=2, No such file or directory
I also tried it with String.execute, I am getting the same exception
1 Like
As explained in the DSL reference , ‘commandLine’ is the full command line. What you want is ‘executable’.
vips
(vipss78)
July 13, 2012, 10:29pm
3
so just replacing commandLine with executable should work? Can it execute shell builtin? Its not a program like -ls
vips
(vipss78)
July 13, 2012, 10:31pm
4
It seems that
exec {
executable ‘ls’
args ‘-ltrh’
}
This thing works, however,
exec {
executable ‘source’
args “${root}/etc/localBuildPorts”
}
this doesn’t work
A shell builtin is not an executable. In that case the executable is the shell.
vips
(vipss78)
July 13, 2012, 10:44pm
6
Can you elaborate? are you saying I should have
executable ‘shell’
??
vips
(vipss78)
July 13, 2012, 11:08pm
7
yeah… but those source values are only available within that subprocess… for example
$ sh -c ‘source $ROOT/buildlocalBuildPorts’ $ echo $FINAL_LOCALTEST_TOMCAT_HTTP_PORT
$ bash -c ‘source $ROOT/buildlocalBuildPorts’ $ echo $FINAL_LOCALTEST_TOMCAT_HTTP_PORT
$ zsh -c ‘source $ROOT/buildlocalBuildPorts’ $ echo $FINAL_LOCALTEST_TOMCAT_HTTP_PORT
$ source $ROOT/buildlocalBuildPorts $ echo $FINAL_LOCALTEST_TOMCAT_HTTP_PORT 9090
the source values is not available outside. So even If I try it with
exec {
executable "sh"
args "-c","source ${root}/etc/localBuildPorts"
}
println System.getenv()['FINAL_LOCALTEST_TOMCAT_HTTP_PORT']
the sourced variables wont be available to gradle. Correct me If I am wrong.
Sourcing a script to make environment variables visible to Gradle won’t work, because Gradle is the parent process.
“sh”, “bash”, “zsh”, or whatever shell you want to use. For example:
task hello(type: Exec) {
executable "sh"
args "-c", "echo 'hello from your shell'"
}
For more information, see the documentation of your shell.