Setting environment variables in build.gradle.kts

China☆狼群 提交于 2020-05-13 14:54:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!