如何为Java 9模块组织常用依赖?

huangapple 未分类评论50阅读模式
标题翻译

How to organise common dependencies for Java 9 modules?

问题

目前我有一个包含多个Maven模块的项目:

  • 根模块,作为所有其他模块的父模块;
  • 一些子模块,其中一些依赖于其他模块。

对于每个模块,除了根模块外,我已经创建了module-info.java文件,在其中列出了适当的依赖关系。

但是,我有一些对于任何模块都是必需的依赖项。在Maven中,我将它们放在根pom.xml文件的dependencies部分。

是否可能只在根模块的module-info.java文件中写一次它们,然后将其导入子模块?

我知道有requires transitive ...命令,但我不知道如何使在根模块的src/java目录中创建的module-info.java文件可以被其子模块的module-info.java文件访问。

英文翻译

For now I have maven project with several maven modules:

  • Root module, used as parent module for all other modules;
  • Some child modules, some of them depending on others.

For each module, except the root one, I've created module-info.java, where I've listed proper dependencies.

But I have some dependencies, required by any module. In maven, I've put them in dependencies section of the root pom.xml.

Is it possible to write them only once in root module's module-info.java, and then import it to submodules?

I know about command requires transitive ..., but I don't know how to make module-info, created in src/java directory of my root module, accessible by it's children's module-infos.

huangapple
  • 本文由 发表于 2020年5月30日 22:23:27
  • 转载请务必保留本文链接:https://java.coder-hub.com/62103794.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定