Book Image

Apache Maven Cookbook

Book Image

Apache Maven Cookbook

Overview of this book

Table of Contents (18 chapters)
Apache Maven Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 the preceding command is shown as follows:

    [INFO] --- maven-help-plugin:2.2:active-profiles (default-cli) @ project-with-profile ---
    [INFO]
    Active Profiles for Project 'com.packt.cookbook:project-with-profile:jar:1.0-SNAPSHOT':
    The following...