问题
In groovy you can set environment variables with environment key value
.
For example for run
you can do:
run {
environment DB_HOST "https://nowhere"
}
How can I accomplish this in Kotlin in build.gradle.kts?
回答1:
Like this:
tasks {
"run"(JavaExec::class) {
environment("DB_HOST","https://nowhere")
}
}
Or if you like the delegation property style:
val run by tasks.getting(JavaExec::class) {
environment("DB_HOST","https://nowhere")
}
来源:https://stackoverflow.com/questions/53222927/setting-environment-variables-in-build-gradle-kts