Why is Maven not using the expected profile?

I use Maven to create some projects, and it uses the gMaven plugin to create an RPM that includes the main artifact. I want Maven to try to create RPMs on systems with rpmbuild, and not on systems that don't, so I built two separate profiles, one of which should be the default, and one that should be activated when in the Unix OS family .

I could swear that I tested it and everything works correctly, but now it works with the profile of the Unix family, even when I create OSX. However, if I change the OS family of the profile to β€œwindows,” he definitely knows that this is not on the Windows machine, and therefore launches the default profile.

Here is the relevant section of my pom.xml file:

<profiles> <profile> <id>default-profile</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <rpmPhase>none</rpmPhase> </properties> </profile> <profile> <id>rpm-profile</id> <activation> <os> <family>unix</family> </os> </activation> <properties> <rpmPhase>package</rpmPhase> </properties> </profile> </profiles> 

In the output of Maven:

 OS name: "mac os x", version: "10.9.4", arch: "x86_64", family: "mac" 

However, Maven sets rpmPhase to "package" instead of "none", which is not the expected behavior.

Can someone see if there is anything here?

EDIT:

In addition, if I install the OS family on something that does not exist, or if I comment on the activation block at all, then the default profile is used, so it seems that Maven is actively matching my OSX with the Unix OS family.

+5
source share
2 answers

I had the same problem, this is a JIRA problem explaining the problem:

https://jira.codehaus.org/browse/MNG-4983

They say that this is actually not a mistake. Here's a workaround if you want OSX and Unix to be separate:

 <os> <family>unix</family> <name>!mac os x</name> </os> 
+5
source

So, after inspection, it looks like OSX matches the "Unix family" under Maven. Apparently, the check box checks for any OS ending in "x" as a Unix family, which seems like a dumb way to do this. Unfortunately, it doesn't seem like you can do any AND or OR statements, so you need to select one family and one family. Because of this, I changed unix to! Mac to avoid problems in OSX. Of course, this will happen if the build was running on Windows.

+1
source

Source: https://habr.com/ru/post/1202624/


All Articles