简体   繁体   中英

How to package jar from one project to another in maven multimodule project

I need a best-practice solution for the following problem. I have a maven multi-module project with 3 subprojects:

  • client-module (simple java app which packaged as .jar)
  • module-1-that-uses-client
  • module-2-that-uses-client

module-*-that-uses-client is a bunch of static xml config files with a client-module.jar which is packaged as a .zip file. So, the packaged structure of a module-*-that-uses-client would look like:

  • client-module.jar
  • config1.xml
  • config2.xml
  • config3.xml

I wonder how I can implement following build strategies. If I build client-module, then:

  1. build client-module
  2. copy client-module.jar to all module-*-that-uses-client
  3. build all module-*-that-uses-client modules.

If I build any of module-*-that-uses-client, then:

  1. build client-module
  2. copy client-module.jar to exact module-*-that-uses-client
  3. build exact module-*-that-uses-client modules.

Appreciate any help on this problem.

One solution would be the usage of --also-make and --also-make-dependents .

--also-make builds all dependencies of the specified module. Example: mvn --projects module-1-that-uses-client --also-make clean install builds client-module and module-1-that-uses-client in this order.

--also-make-dependents builds the specified module and all other modules with a dependency to the specified module. Example: mvn --projects client-module --also-make-dependents clean install builds first client-module and then both module-*-that-uses-client.

See also the Guide to Working with Multiple Modules .

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