标题翻译
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.
专注分享java语言的经验与见解,让所有开发者获益!
评论