Activating/deactivating a Maven profile

A profile can be specified in pom.xml or settings.xml. Each profile may be created for a specific purpose; for instance, to run on a particular platform or to run in an integration environment. All profiles may not need to run in all cases. Maven provides a mechanism to activate and deactivate a profile as required.

Getting ready

Use the project where we created the profile to add a new Maven profile section.

How to do it...

Let's perform the following steps to activate/deactivate a Maven profile:

  1. To deactivate a profile, set the following value in the activeByDefault element:
    <activeByDefault>false</activeByDefault>
  2. Run the Maven command to check if the profile is active:
    mvn help:active-profiles
    

    The output for ...

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.