zjffdu
zjffdu

Reputation: 28944

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

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?

Upvotes: 8

Views: 6909

Answers (2)

VonC
VonC

Reputation: 1328602

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.

Upvotes: 10

coffman21
coffman21

Reputation: 1062

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.

Upvotes: 2

Related Questions