Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I assign a specific maven profile to an intellij run configuration?

I have multiple projects loaded into my project structure and they all use different maven profiles. I know I can switch up the profiles using the Maven Projects tab but I would like to assign a specific profile to go along with a specific run configuration.

like image 956
Grammin Avatar asked Jun 23 '16 20:06

Grammin


People also ask

How do I run a specific profile in Maven?

Open Maven settings. m2 directory where %USER_HOME% represents the user home directory. If settings. xml file is not there, then create a new one. Add test profile as an active profile using active Profiles node as shown below in example.

How does IntelliJ choose Maven?

In the Project tool window, right-click your project and select Add Framework Support. In the dialog that opens, select Maven from the options on the left and click OK. IntelliJ IDEA adds a default POM to the project and generates the standard Maven layout in Project tool window.

How do I assign a profile in IntelliJ Maven?

You can assign specific profiles via the dialog "Edit Run Configurations". See this screenshot: AFAIK, this profile setting overrides the choice which you select in the maven view of IntelliJ. Thanks for contributing an answer to Stack Overflow!

What is build profile in Maven?

A Build profile is a set of configuration values, which can be used to set or override default values of Maven build. Using a build profile, you can customize build for different environments such as Production v/s Development environments.

Where to configure Maven 3 profiles?

But, in Maven 3, we can actually add profiles to any of three locations: Note that Maven 2 did support a fourth location, but this was removed in Maven 3. We try to configure profiles in the pom.xml whenever possible. The reason is that we want to use the profiles both on our development machines and on the build machines.

How do I create a profile in IntelliJ IDEA?

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.


2 Answers

If You have created maven profiles in your pom.xml, you should be able to see the profiles in right side of Intellij Idea

You can select this profile

If there will be multiple profile you can activate one by default

           <activation>
                <activeByDefault>true</activeByDefault>
            </activation>

Or for running specific profile we can select mvn install -Pbuild-profile

like image 92
Vijendra Kumar Kulhade Avatar answered Oct 06 '22 19:10

Vijendra Kumar Kulhade


You can assign specific profiles via the dialog "Edit Run Configurations". See this screenshot:

enter image description here

AFAIK, this profile setting overrides the choice which you select in the maven view of IntelliJ.

like image 26
JimHawkins Avatar answered Oct 06 '22 18:10

JimHawkins