IntelliJ: activate Maven profile when running Junit tests

I declared some properties specific to Maven profiles. Part of my pom.xml:

<profiles> <profile> <id>release</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <my.properties.file>foo.xml</my.properties.file> </properties> </profile> <profile> <id>ci</id> <properties> <my.properties.file>bar.xml</my.properties.file> </properties> </profile> </profiles> 

I'm having some problem using Maven's "ci" profile when I run Junit tests through IntelliJ IDEA 2016.
I activate my profile through the Maven Projects panel, then run the tests. The problem is that the value of the property "my.properties.file" is equal to "foo.xml" and not "bar.xml".

I have no problem with the command line (I can use the "-Pci" flag). How can I tell IntelliJ to use the "ci" profile? thanks.

+7
java intellij-idea maven junit
source share
1 answer

You must add profiles to the setup.xml Maven file (you must find it in the path $ {YOUR_MAVEN_HOME} \ apache-maven-3.1.1 \ conf \ setting.xml). Then you need to open intellij, click View> Tools> Maven Projects. There you should see your profiles (ci and release) and select the correct one.

Hope this helps you.

+1
source share

All Articles