简体   繁体   中英

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.

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.

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. 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. This is from the Maven website: 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM