我正在使用play-application
插件,该插件又使用基于gradle规则的模型配置。 build.gradle.kts
看起来像这样:
plugins {
`play-application`
}
/* the snippet does not work
model {
components {
play {
platform play: playVersion, scala: scalaVersion, java: javaVersion
injectedRoutesGenerator = true
}
}
}
*/
// this works instead
apply(from = "play_setup.gradle")
val setup: groovy.lang.Closure<Any?> by extra
setup(project, jVersion, scalaVersion, playVersion)
其中play_setup.gradle是:
ext.setup = { project, javaVersion, scalaVersion, playVersion ->
model {
components {
play {
platform play: playVersion, scala: scalaVersion, java: javaVersion
injectedRoutesGenerator = true
}
}
}
}
是否有办法停止对基于规则的模型制作的插件使用groovy并直接通过kotlin-DSL对其进行配置?
答案 0 :(得分:1)
不符合Gradle Kotlin DSL入门中列出的limitations。
Kotlin DSL将不支持
model {}
块,该块是 discontinued Gradle Software Model。但是,您可以应用模型 脚本中的规则-有关更多信息,请参见model rules sample
文档中指向模型规则示例的链接已断开,但我已在上面对其进行了修复。