Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build sub module's child module via maven build argument

Tags:

java

maven

Here's my project structure:

 ├── module_1
     ├── sub_module
          ├── module_11
          ├── module_12
          ├── module_13
 ├── module_2

Now if I build it with the following command:

$~ mvn package -pl sub_module

It would only build sub_module but not its children module.

The only way to build module_11/module_12/module_13 is to specify them explicitly as following:

$~ mvn package -pl sub_module,sub_module/module_11,sub_module/module_12,sub_module/module_13

This is inconvenient for me, just wondering if there is an easier way approach this?

like image 736
zjffdu Avatar asked Feb 01 '18 05:02

zjffdu


2 Answers

Check if adding the -am or -amd option helps

mvn clean package -pl sub_module -am
mvn clean package -pl sub_module -amd  <== (confirmed by the OP)

see at Maven Tips and Tricks: Advanced Reactor Options:

-am, --also-make

If project list is specified, also build projects required by the list

-amd, --also-make-dependents

If project list is specified, also build projects that depend on projects on the list.

like image 108
VonC Avatar answered Nov 18 '22 13:11

VonC


I've got two kludges that may fit:

Run build on specific pom file using -f:

$ mvn package -f module_1/submodule

Or cd into required module and simply build it:

$ pwd
/module_1
$ cd submodule
$ mvn package

It, howewer, takes more pain moving across directories.

like image 1
coffman21 Avatar answered Nov 18 '22 13:11

coffman21