Maven - 将 pom 的所有子模块作为依赖项包含在另一个模块中
我们有一个 Maven 模块,其设置如下:
a (parent)
-> b (submodule)
-> c (submodule)
-> d (submodule)
这个子模块列表设置为随着时间的推移而增长(到 20 个左右的列表)。我们有另一个模块,它将包含 a 的所有子模块作为依赖项。有没有一种巧妙的方法可以做到这一点,而不必手动保持子模块列表与依赖项列表同步。即有没有办法将一个和所有子模块作为依赖项包含在内?
We have a maven module that is set up as so:
a (parent)
-> b (submodule)
-> c (submodule)
-> d (submodule)
This list of submodules is set to grow as time goes on (to a list of 20 or so). We have another module that will include as dependencies all submodules of a. Is there a neat way of doing this, rather than having to manually keep the submodule list in sync with the dependencies list. I.e. is there any way of including a and all submodules as a dependency?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您在这里有几个选择:
我认为选择#4可能是正确的,但我对你的情况不够熟悉。
You have a few choices here:
I think choice #4 is probably right, but I am not familiar enough with your situation.
撇开设计考虑不谈,这很容易完成 - 只需在指向父 pom 的依赖项中包含
pom
即可。例如:Design considerations aside, this is easily done - simply include
<type>pom</type>
in your dependency pointing at the parent pom. E.g:“自动”包含依赖项的唯一方法是通过传递依赖机制,并且它只能通过拉取依赖项的依赖项来工作,因此除非您有一个依赖于所有子模块的 pom,不,如果不列出,您将无法获得它们他们都出去了。需要这样做表明您的项目设计中存在缺陷。如果模块是“全部或无”,那么它们可能不是单独的模块。
The only way dependencies get "automatically" included is via the transitive dependency mechanism, and it only works by pulling in dependencies of dependencies, so unless you have a pom that depends on all the submodules, no, you won't get them without listing them all out. A need to do this points to a flaw in your project design. If the modules are "all or none", then they're probably not separate modules.