How do I compile a single module in the following scenario of two multi-module Maven projects A and B.
Both projects are located in the same directory so that the directory structure looks like this:
root
|-- A
| |-- A1
| |-- A2
| `-- A3
`-- B
|-- B1
`-- B2
All directories except root have their own pom.xml files and each submodule is referencing its parent module (A1 has parent A, etc.) and the parent is referencing its submodules (A has modules A1-A3). The problem I have is that A1 depends also on B1, since project B is a collection of utilities that I want to use in other projects.
My question is how do I reference B1 correctly so that I can build A1 without having to install B1 first. I mean I want to build A1 with all its dependencies using one maven command.
My current solution is to make B1 a module of A (via module reference ../B/B1
). Then I can call mvn package
from directory A and it works fine. But building the whole project A is sometimes very time consuming. Therefore I would like to build only A1 + deps. How can I do that? When I call mvn reactor:make -Dmake.folders=A1
from directory A I get the following build error:
Reason: Cannot find parent: B:B for project: B:B1:jar:1.0-SNAPSHOT for project B:B1:jar:1.0-SNAPSHOT
So it seems that maven suddenly cannot find B1's parent module anymore when using the reactor plugin. Does anybody know a solution for that or an alternative approach for referencing a submodule from another project that allows building A1 in the way described above?
Note, I don't want to set up a super module in root that includes modules A and B, because this pom file, because every user that checks out A and B might have also other projects in his root directory and therefore would have to write his own pom file for root.