如何在 gradle kotlin DSL 中配置 gradle 规则库模型插件?
How to configure gradle rule base model plugin in gradle kotlin DSL?
我正在使用 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 配置它们?
不是根据 Gradle Kotlin DSL 入门中列出的 limitations。
The Kotlin DSL will not support the model {}
block, which is part of
the discontinued Gradle Software Model. However, you can apply model
rules from scripts — see the model rules sample for more information
模型规则示例的 link 在文档中被破坏,但我在上面修复了它。
我正在使用 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 配置它们?
不是根据 Gradle Kotlin DSL 入门中列出的 limitations。
The Kotlin DSL will not support the
model {}
block, which is part of the discontinued Gradle Software Model. However, you can apply model rules from scripts — see the model rules sample for more information
模型规则示例的 link 在文档中被破坏,但我在上面修复了它。