Maven Modules + Building a Single Specific Module

I have a multi-module Maven project with a parent project P and three sub-modules A, B, and C. Both B and C are war projects and both depend on A.

I can type mvn compile in P and have all of the sub-modules properly compiled. The problem comes when I want to do operations for specific modules.

I’d like to be able to package a war for project B, but when I run the package command from B‘s directory, it complains that it can’t find the dependencies for A.

I understand from this question: Maven and dependent modules that perhaps Maven isn’t really designed for this type of dependency resolution, but that begs the question of how do I package B?

  1. Do I have to run mvn package for the entire project hierarchy when I really just want B?

  2. Do I have to install snapshots of A into my local repository every time I want to package B?

This second scenario isn’t much fun when A is still under active development.

Any best practices here?

6 s
6

Leave a Comment