gpt4 book ai didi

java - 在 gradle 的子项目中的根项目中定义的依赖项会发生什么情况?

转载 作者:太空宇宙 更新时间:2023-11-04 14:04:59 24 4
gpt4 key购买 nike

我有一个包含多个子项目的 gradle 项目。我在根项目中定义了几个带有版本号的依赖项,但并非所有子项目都使用所有这些依赖项。

root
- build.gradle
- compile 'math:math:1.0.0'
- settings.gradle
- include 'messages'
- include 'message-handler'
\ messages
- build.gradle
- //no math
\ message-handler
- build.gradle
- compile 'math:math'

我的消息项目工件是否包含对数学库的依赖?

换句话说,如果我创建一个依赖于 Nexus 存储库中的消息工件的单独项目,我的依赖树会显示这个新项目的数学库吗?

最佳答案

是的 - 您的消息项目工件将包含对数学库的依赖项。

根据Gradle Documentation :

For most multi-project builds, there is some configuration which is common to all projects. In our sample, we will define this common configuration in the root project, using a technique called configuration injection. Here, the root project is like a container and the subprojects method iterates over the elements of this container - the projects in this instance - and injects the specified configuration

换句话说,根项目中包含的每个配置都适用于所有子项目。

关于java - 在 gradle 的子项目中的根项目中定义的依赖项会发生什么情况?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28946802/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com