patternjavaCritical
Maven Modules + Building a Single Specific Module
Viewed 0 times
mavenmodulespecificsinglebuildingmodules
Problem
I have a multi-module Maven project with a parent project
I can type
I'd like to be able to package a war for project
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
-
Do I have to run
-
Do I have to install snapshots of A into my local repository every time I want to package
This second scenario isn't much fun when
Any best practices here?
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? -
Do I have to run
mvn package for the entire project hierarchy when I really just want B? -
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?
Solution
Any best practices here?
Use the Maven advanced reactor options, more specifically:
So just
And this will build B and the modules required by B.
Note that you need to use a colon if you are referencing an
As described here:
Use the Maven advanced reactor options, more specifically:
-pl, --projects
Build specified reactor projects instead of all projects
-am, --also-make
If project list is specified, also build projects required by the listSo just
cd into the parent P directory and run:mvn install -pl B -amAnd this will build B and the modules required by B.
Note that you need to use a colon if you are referencing an
artifactId which differs from the directory name:mvn install -pl :B -amAs described here:
- Define modules list which shall be build in Maven multiproject build
Code Snippets
-pl, --projects
Build specified reactor projects instead of all projects
-am, --also-make
If project list is specified, also build projects required by the listmvn install -pl B -ammvn install -pl :B -amContext
Stack Overflow Q#1114026, score: 1009
Revisions (0)
No revisions yet.