Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to undersand how I can pass arguments from gradle to my shell script?

I'm trying to pass command line arguments to my shell script through a gradle task myconfiguration is like this below.

task dosomething(type:Exec) {
  workingDir 'dir'
  executable 'sh'
  args '-c','source dosomething.sh $arg'
}

And I'm trying to pass it by doing the the following command in the terminal:

$ gradle dosomething -Parg=foo

And it does not work am I doing something wrong?

like image 380
ZekeJackhammer Avatar asked Jan 14 '23 05:01

ZekeJackhammer


1 Answers

Groovy only performs String interpolation for double-quoted Strings. (That's one of the reasons why I use double quotes by default.) Try:

...
args "-c", "source dosomething.sh $arg"
like image 130
Peter Niederwieser Avatar answered Feb 05 '23 18:02

Peter Niederwieser