Maven Commands for Building Specific Modules

In my job, we work with a maven multi-module project. While using maven, I have discovered several commands that are quite effective during development. In this post, and in the upcoming posts I am planning to share those.

So, today's post is regarding Maven command to build a specific project. For instance, we have a project, with three modules: A, B, and C, where C depends on B and B depends on A. And we are working with B at this moment. Using following command, we can run different maven phases on module B as follows.

mvn -pl :B clean install 

We can include multiple projects as follows :A, :B.

What is more interesting is that the following command run maven command not only this module, but also the modules that depends on it.

mvn -pl :B clean install -amd 

The above command in effect includes module C.

Using –am command, we can include all the dependencies as well, which is module A in this example.

Hope this helps!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s