Book Image

Apache Maven Cookbook

Book Image

Apache Maven Cookbook

Overview of this book

Table of Contents (18 chapters)
Apache Maven Cookbook
About the Author
About the Reviewers

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 User profile as defined in the user settings file (in the .m2 subfolder of the user's HOME folder)

  • A Global profile as defined in the global settings file (in the conf folder of M2_HOME)

By creating different profiles for different variations of the...