I require the following 6 arguments to be passed to a JavaExec task:
–project=abc --dbRegion=def --j2JschemaClass=com.b.A --j2JuserFile=…/a/sql/users.sql --jinjaFilePath=…/a/infra/r.yaml --jinjaEntry="- name: relational_db,properties:,instanceName:"
so I can pick them up as the args String array argument in my main method.
public static void main(String args) {
…
}
I must be able to pass spaces to the last argument in particular. The quote type (if any) for the 6th argument does not matter, as long as it appears as one argument for the main method.
I have tried passing these as
-Pargs="<arguments ‘above’>"
-Pargs=’<arguments “above”>’
-Dargs="<arguments ‘above’>"
-Dargs=’<arguments “above”>’
And picking them up in the task:
task relationalPurge(type: JavaExec) {
args = System.getProperty(‘args’, ‘’) //If using -D
args = getProperty(‘args’) //If using -P
}
I get the following error when running gradle:
Project ‘name’ not found in root project…,
or
Unknown command line option --dbRegion.
So I don’t even get to the task as the quotes are not working to delimit parameters with spaces (6th argument) or to allow passing multiple arguments.
Any ideas?
Alternatively is there a way I can just pass one string as a single argument and then split it manually in gradle according to my needs - I could split by “–” and trim?