Reputation: 14052
We have a monorepo and now try to get Maven to compile our various Java programs.
An example directory tree might look like:
pom.xml
src/main/java/com/company
| program12
| Main.java
| pom.xml
| mod1
| Sweet.java
| pom.xml
| mod2
| Sour.java
| pom.xml
| program2
| Main.java
| pom.xml
In both mod1
and mod2
I can package the jars just fine.
I now would like for e.g. program12
to build and include mod1
and mod2
and program2
to build and include only mod2
.
Therefor I added the necessary dependencies to both pom.xml
s. Calling mvn package
in program12
and program2
complains that the modules cannot be found in remote repos.
How can I tell Maven to not bother with remote repos and use the local Modules?
I tried adding modules
to the root pom.xml
but that did not change the behavior.
There is probably a part of the logic of Maven I have not yet understood. Would be nice if someone could clear that up.
Upvotes: 1
Views: 27
Reputation: 35795
I think your misunderstanding is the following:
To resolve module dependencies, you need to build the project from the root POM, i.e. go to the POM that contains the modules and run something like mvn clean package
there. It will then build the modules in the correct order and resolve dependencies between them.
If you only want build some modules, you can use parameters like -pl
and -am
.
Upvotes: 1