With Java plugin test task in Gradle, how can I print the environment map for the JVM process which executes the tests.
test.doFirst {
environment 'KAFKA_PORT', "${KAFKA_TCP_9902}"
environment 'DB_PORT', "${MYSQL_TCP_3306}"
// How to print the map of all environments set so far?
}
You can access the environment
map directly. Just loop through it and print the values over the keys:
test.doFirst {
[...] // do something
environment.each { k, v -> println "${k}:${v}" }
}
Both the map property and two methods to add values, one of them you use, are named environment
. By default, the environment variables from the Gradle process are used.
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