简体   繁体   中英

Maven share project across multiple different projects

I read a lot of almost similar question, but I have different problem then others.

I have 3 projects:

  1. Project_A
  2. Project_B
  3. Project_Shared

Solution 1: Local installed jar

I want to develop Project_A independently from Project_B. But both use Project_Share, which I also want to develop - this is why I can't manually make one jar from Project_Share and install it in local Maven repository.

Solution 2: Two different parent pom

I also really don't want to change Project_A and Project_B structure - through adding for them two different maven parent pom. As far as I understand - I can add parent pom for two module: Project_A and Project_Share and then I could run Project_A using Parent project. And I can't run Project_A directly from it (this will complain about Project_Shared jar missing - am I right?

Ideal solution:

Configure maven for Project_A in such way that after I run Project_A, it will look to directory of Project_Shared, compile it, and obtain its jar, then build Project_A with this jar, and run Project_A.

Question:

Is it possible to obtain ideal solution? Or is there any better solution? Or maybe I misunderstand something?

Thanks for Your help!

Do I get you right that Project_A and Project_B are two different projects (none of them is parent of the other) so that they should be completely independet?

You have Project_A and Project_B with their own pom.xml . Both are dependet from Project_Shared. So Project_Shared has it's own pom.xml which is referenced by the other project poms as dependencies .

Initially you call mvn install for Project_Shared. After that you can build the other projects. You do the same thing if you want to change Project_Shared and the change should be accessible for both projects.

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