5

I am using Maven to build some projects and it's using the gMaven plugin to build an RPM that includes the main artifact. I only want Maven to attempt to build the RPM on systems that have rpmbuild, and not on systems that do not, so I built two separate profiles, one that is supposed to be default and one that is supposed to activate when on a Unix family OS.

I could have sworn that I tested it and everything worked correctly, but now it is running the Unix-family profile even when I build on OSX. However, if I change the profile's OS family to "windows" it definitely knows it is not on a Windows machine and therefore runs 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 Maven output:

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

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

Can anyone see if I'm missing something here?

EDIT:

Also, if I set the OS family to something that doesn't exist, or if I comment out the activation block altogether then the default profile is used, so it seems that Maven is actively matching my OSX with a Unix family OS.

4

2 回答 2

5

我遇到了同样的问题,这是一个解释问题的 JIRA 问题:

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

他们说它实际上不是一个错误。如果您需要将 OSX 和 Unix 分开,这里有一个解决方法:

<os>
  <family>unix</family>
  <name>!mac os x</name>
</os>
于 2015-01-22T22:35:17.667 回答
1

因此,环顾四周后,OSX 似乎与 Maven 下的“Unix 系列”相匹配。显然,该检查将任何以“x”结尾的操作系统标记为 Unix 系列,这似乎是一种愚蠢的做法。不幸的是,您似乎无法执行任何 AND 或 OR 运算符,因此您必须选择一个族,并且只能选择一个族。因此,我将 unix 更改为 !mac 至少避免了 OSX 下的问题。当然,如果构建在 Windows 上运行,它仍然会出现。

于 2014-09-16T15:00:31.333 回答