How do you control Maven Profiles properly?
Hi,
We have a maven project with a parent pom specifying two profiles, mini (the default) and max, and several child modules (mini uses two, max all). Each child module can define further profiles.
When I was running mvn clean install form within IntelliJ (via mvn menu), I got failing tests. From Terminal, everything was working fine. Eventually, I realised IntelliJ kicked off mvn with -P min,!max,!nexus,!xyz - and one of the modules that has failing tests got run as well.
What is that -P with exclamation mark, what does it do, and why was it set?
When I had a closer look, I also realised that the ticks in front of activated profiles come in two shades of grey.

After much trying, I finally managed to get them set in the right way, so that IntelliJ only runs mvn install -P mini (with no exclamation mark profiles). The help doesn't seem to explain how to do this. Can someone please explain how to use this confusing "feature" properly, and how to convince IntelliJ to supply the -P I expect, without appendage?
Finally, how do you run mvn via menu without a -P at all?
Cheers,
Christian
Please sign in to leave a comment.
You can create run configuration and remove profiles from the list:
See also http://maven.apache.org/guides/introduction/introduction-to-profiles.html:
Hi Serge,
Thank you for your reply. I understand that I can create my own run configurations. I also guessed that the !profile means don't run that profile.
But I still have trouble understanding IntelliJ's default behaviour:
Last but not least, your link to the maven doc is interesting, but I still don't quite understand how maven resolves the scenario where -P mine on a parent would implicitly run profile moduleProfile on a child, when you specify -P mine,!moduleProfile... Do you happen to have a link to documentation about parent/child pom structure and how that gets resolved?
Kind regards,
Christian
I'm not Maven expert and can't explain how it works for parent/child modules, sorry.
There are 3 states of the checkbox indicating profile type (NONE, IMPLICIT and EXPLICIT): https://github.com/JetBrains/intellij-community/blob/78d1492242539eb0d5e36016f9dc1f9b55d76f94/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsStructure.java#L136-L136.
@Christian Balzer
I have the same query as you