O'Reilly logo

Apache Maven Cookbook by Raghuram Bharathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Selectively building modules

When a project has a number of modules, there may be situations when we might want to selectively build modules. One such situation could be because the module might run only on specific machines. Another reason could be that a module may have long-running tests that may make sense only in test servers.

Let us see how we can selectively build modules by using the profile feature of Maven.

How to do it...

  1. Open a multi-module project that has two modules (two-multi-module), namely common-one and dev-two.
  2. In the parent pom, add one project to the modules section:
      <modules>
          <module>common-one</module>
      </modules>
  3. Define a profile and include both modules:
    <profiles> <profile> <id>dev</id> <modules> <module>common-one</module> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required