Kotlin DSL中的等效功能是什么:
run {
systemProperties["spring.output.ansi.enabled"] = "always"
}
我试过了:
run {
systemProperties("spring.output.ansi.enabled" to "always")
}
但是得到了:
* What went wrong: Script compilation error:
Line 37: systemProperties(Pair("spring.output.ansi.enabled", "always"))
^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public inline fun JavaExec.systemProperties(vararg properties: Pair<String, Any?>): JavaExec defined in org.gradle.kotlin.dsl
public inline fun Test.systemProperties(vararg properties: Pair<String, Any?>): Test defined in org.gradle.kotlin.dsl
public inline fun JavaForkOptions.systemProperties(vararg properties: Pair<String, Any?>): JavaForkOptions defined in org.gradle.kotlin.dsl
最佳答案
我相信Kotlin会误认为run块为其内置的run方法。
如果您指的是应用程序的插件,则可以使用以下命令配置其运行时属性
application {
applicationDefaultJvmArgs = listOf("-Dspring.output.ansi.enabled=always")
}
在这里查看更多:
https://docs.gradle.org/current/userguide/application_plugin.html
关于gradle - 如何在Kotlin DSL中的 `run`上设置系统属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53898859/