且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Gradle Kotlin DSL:如何使用Typesafe API配置子项目

更新时间:2023-11-19 23:39:10

等级6.1.1 类型安全的模型访问器读取:

只有主项目构建脚本和预编译的项目脚本插件具有类型安全的模型访问器.初始化脚本,设置脚本,脚本插件没有. 这些限制将在将来的Gradle版本中删除.

无论未来版本"是什么意思,而跨-配置项目内容如下:

Whatever "future release" might mean ...while Cross-configuring projects reads:

跨项目配置是一种机制,您可以通过该机制从另一个项目的构建脚本中配置一个项目.一个常见的示例是在根项目构建脚本中配置子项目时. 采用这种方法意味着您将无法对插件贡献的模型元素使用类型安全的访问器.相反,您将不得不依赖字符串文字和标准的Gradle API.

Cross project configuration is a mechanism by which you can configure a project from another project’s build script. A common example is when you configure subprojects in the root project build script. Taking this approach means that you won’t be able to use type-safe accessors for model elements contributed by the plugins. You will instead have to rely on string literals and the standard Gradle APIs.