我试图创建一个科特林项目,有时候会包含Java源代码的生成文件。在与多项目构建的基于Groovy构建文件过去,我可以指定sourceCompatibility
在subproject
没有问题的块。随着科特林DSL我知道那一定是在java
块与科特林DSL配置,但是当我试图做到这一点从subproject
我的根块build.gradle.kts
文件,我得到一个编译错误:
Script compilation errors:
Line 14: java {
^ Expression 'java' cannot be invoked as a function. The function 'invoke()' is not found
Line 14: java {
^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public val PluginDependenciesSpec.java: PluginDependencySpec defined in org.gradle.kotlin.dsl
Line 15: sourceCompatibility = JavaVersion.VERSION_1_8
^ Unresolved reference: sourceCompatibility
3 errors
我已经包含了要点,以我使用gradle这个构建文件。现在,我可以得到它,如果我的子项目之一指定Java块工作build.gradle.kts
的文件,但我想应用到所有子项目的设置,不仅仅是具体项目。
你可以只用
configure<JavaPluginExtension> { ... }
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句