Equivalent to java -Dprop="abc" app
, but using groovy, like groovy -Dprop="abc" app.groovy
Basically the same question asked here, but negative answers there are relatively old. Anything new support this since 2007?
The getProperty(String key) method in Java is used to returns the system property denoted by the specified key passed as its argument.It is a method of the java. lang. System Class. where key is the name of the System property.
System properties are set on the Java command line using the -Dpropertyname=value syntax. They can also be added at runtime using System. setProperty(String key, String value) or via the various System. getProperties().
Sure; it works as-is:
$ cat sysenv.groovy
println System.getProperty("wat")
$ groovy -Dwat="hello" sysenv.groovy
hello
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