Understanding Maven profiles

Maven is designed to create portable builds that are expected to work across different platforms and in various runtime environments.

Now, there may be situations where you need to build the same project differently. For instance, you may need to build a project differently for the purpose of staging and production. You may not want to build a project that requires a Linux library on Windows.

How to do it...

Let's understand Maven profiles by performing the following steps:

  1. Open settings.xml in the conf subfolder of your Maven installation (as specified in M2_HOME).
  2. View the commented section of profiles.

How it works...

Maven provides three type of profiles:

  • Per Project profile as defined in the pom file of the project
  • Per ...

Get Apache Maven Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.