I would like to use the properties injection of command line Gradle to pass it an array, is this possible?
Something like this:
gradle build -PmyProp=['value1','value2','value3']
And access it like usual:
if(project.hasProperty('myProp')) {
for ( prop in myProp ) {
...
}
}
Is this possible?
You cannot pass array as value of a property. However you can accept a comma separated string as value and split inside your gradle file.
if (project.hasProperty('myProp')) {
project.properties['myProp'].split(',').each {
println it
}
}
Run as gradle build -PmyProp=value1,value2,value3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With