Maven profiles
IntelliJ IDEA lets you use Maven build profiles which can help you customize builds for a particular environment, for example, production or development.
Declare Maven profiles
IntelliJ IDEA lets you declare profiles explicitly in the POM of your project. Using code completion, you can place a number of different configurations inside the profiles
tags and override the default configurations specified in your POM for Maven plugins, dependencies, repositories, and so on.
Open your POM in the editor.
Specify the
<profiles>
section and declare the profiles.IntelliJ IDEA displays them in the Profiles list of the Maven tool window.
Alternatively, you can declare profiles using one of the following ways:
You can define them locally in the Maven settings directory %USER_HOME%/.m2/settings.xml.
You can define them globally in the global Maven settings ${maven.home}/conf/settings.xml.
You can define them in the profile descriptor located in the project's base directory (profiles.xml). Note that this option is not supported in Maven 3.0. See Maven 3 compatibility notes.
Activate Maven profiles
You can activate a profile in the Maven tool window using the Profiles node and the corresponding profiles' checkboxes.
Open the Maven tool window.
Click the Profiles node to open a list of declared profiles.
Select the appropriate checkboxes to activate the profiles you need. You can have several active profiles. When they are activated, their configurations are merged based on the POM profile declaration.
You can also activate profiles automatically according to a range of contextual conditions for example, JDK version, OS name and version, presence or absence of a specific file or property, but you still need to specify all the parameters inside your POM.
You can declare a Maven profile with the activeByDefault
tag in the POM that activates only if Maven doesn’t find any other active profiles. For more information, refer to Maven profiles. IntelliJ IDEA displays the activeByDefault
profile in the Maven tool window with the selected checkbox that is greyed out. You can manually de-activate this profile by clicking the checkbox. Also note that if you manually activate any other profile, the activeByDefault
profile will be de-activated. When you work with multi-module projects, keep in mind that if you specified the activeByDefault
profile in your POM it will be de-activated when you manually activate any other profile even if it is declared in the POM of a different module.