简体   繁体   English

如何引用多模块Maven项目?

[英]How can I reference a multi-module maven project?

I have a multimodule project, let's call it "multi". 我有一个多模块项目,我们称它为“多”。 it generates like 5 jar artifacts. 它会生成5个jar伪像。

I would like to simply reference "multi" from another project's pom and get everything i need, without having to indivdivually reference each of the 5 jar's generated by "multi" in my the referencing pom file. 我想简单地从另一个项目的pom引用“ multi”并获得我需要的一切,而不必在我引用的pom文件中单独引用“ multi”生成的5个jar的每个。

Isn't that possible? 那不可能吗?

You can create a sixth module (container artifact) in the "multi" project and have it depend on the 5 artifacts you have. 您可以在“ multi”项目中创建第六个模块(容器工件),并使它取决于您拥有的5个工件。 Then you only reference this new module in the other project. 然后,您仅在另一个项目中引用此新模块。

multi:
   - artifact1
   - artifact2
   - artifact3
   - artifact4
   - artifact5
   - containerArtifact has all the above five as dependencies.

In the other project: 在另一个项目中:

<dependency>
  <groupId>groupId</groupId>
  <artifactId>containerArtifact</artifactId>
 </dependency>

You need a new module to work as the assembler plugin. 您需要一个新模块作为汇编程序插件。 This module will collect all dependencies for the other modules and create the package you want. 该模块将收集其他模块的所有依赖关系,并创建所需的包。

This is done through the mavenassemblyplugin. 这是通过mavenassemblyplugin完成的。 This is from the Maven website: http://maven.apache.org/plugins/maven-assembly-plugin/ 这来自Maven网站: http : //maven.apache.org/plugins/maven-assembly-plugin/

Examples can be found here: http://maven.apache.org/plugins-archives/maven-assembly-plugin-2.4/examples/index.html 可以在这里找到示例: http : //maven.apache.org/plugins-archives/maven-assembly-plugin-2.4/examples/index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Maven说我在多模块项目中有一个循环引用,但不知道为什么 - Maven says I have a cyclic reference in multi-module project but can't figure out why 我如何编译一个多模块Maven项目,其中一个模块同时具有clojure和Java代码 - How can I compile a multi-module maven project, where a module have both clojure and java code 如何分发多模块Maven项目 - How to distribute a multi-module maven project 如何重组Maven多模块项目? - How to restructure Maven multi-module project? 如何打包多模块maven项目? - How to package multi-module maven project? 如何在没有指定版本的情况下拥有多模块Maven项目? - How can I have a multi-module Maven project without specifying the version all over the place? 在多模块Maven项目中构建所有模块后,如何运行集成测试? - How can I run integration tests after building all modules in a multi-module Maven project? 在 Maven 多模块项目中,如何在一个孩子上运行完整构建并运行特定插件? - In a Maven multi-module project, how can I run a full build and run a specific plugin on one child? 在Maven多模块项目中,如何在一个孩子中禁用插件? - In a Maven multi-module project, how can I disable a plugin in one child? 如何在多模块 Maven 项目中使用以前构建的 jars? - How can I use previously built jars in a multi-module maven project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM