Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build maven parent and select number of modules?

Tags:

maven-2

I have a multi-module maven project.

To build the parent alone, I run mvn package -N (where -N is "non-recursive").

To build a few modules, I run mvn package -pl api,servie (where -pl is "projects").

How do I combine these two in order to build the api, service and the parent?

like image 931
Yuriy Nemtsov Avatar asked Sep 09 '11 23:09

Yuriy Nemtsov


People also ask

What is a multi-module Maven project?

A multi-module project is built from an aggregator POM that manages a group of submodules. In most cases, the aggregator is located in the project's root directory and must have packaging of type pom. The submodules are regular Maven projects, and they can be built separately or through the aggregator POM.

How do I skip a module in Maven build?

Maven version 3.2. 1 added this feature, you can use the -pl switch (shortcut for --projects list) with ! or - (source) to exclude certain submodules. Be careful in bash the character ! is a special character, so you either have to single quote it (like I did) or escape it with the backslash character.


2 Answers

mvn package -pl api,service --also-make

(where --also-make makes the dependencies as well)

like image 50
Yuriy Nemtsov Avatar answered Oct 12 '22 10:10

Yuriy Nemtsov


How about mvn package -pl api,service,. ('.' indicating the project in the current directory) or mvn package -pl api,service,:parent (where "parent" is the artifactId of the parent module).

Arguments to -pl can either be the relative path to a directory containing a maven module or a coordinate in the form [groupId]:artifactId of a module in the current project. If no groupId is supplied, the groupId of the pom being built is used.

like image 42
Ryan Stewart Avatar answered Oct 12 '22 10:10

Ryan Stewart