Activate certain Maven profile in Intellij IDEA only

intellij-idea, maven-3

Solution

If you import a maven project in intellij, you can choose profiles in the maven tool window (usually on the right of the screen). Once these profiles are selected they will persist in the project configuration for that project and will become effective every time the project loads, until you choose to change them. These profile selections will only affect intellij and instances of maven run within intellij.

Another way to achieve this is in Intellij's maven configuration, by specifying a settings file that is specific to intellij development. This can be a copy of your standard settings, named something like `intellij-settings.xml`, but you can add an active profiles section to it:

<activeProfiles>
  <activeProfile>intellij-specific-profile</activeProfile>
</activeProfiles>

Be sure to specify the settings file in your intellij maven config before importing the project. That way it will apply to all projects on import.

Problem

I'm looking for a way to activate the certain profile, which includes some dependencies and settings, related to the development mode only, when the project is opened in IDEA. I know that you can specify the profile to be used - on project import, or in "Maven projects" tab. However it requires some interactions, which are easy to forget. So it would be nice to instruct idea to always activate the appropriate profile, may be by providing some property or runtime configuration, or whatever. This profile should be active only for IDEA import.

Original source