为什么一位开发人员的构建没有正确评估 Maven 配置文件激活表达式?

问题描述 投票:0回答:1

我在平台上工作,有大量 Maven 构建的服务。他们中的很多人都有这样的结构:

<profiles>
    <profile>
        <id>local</id>
        <properties>
            <build.profile.id>local</build.profile.id>
            <skip.unit.tests>false</skip.unit.tests>
            <skipITs>true</skipITs>
        </properties>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
    </profile>
    <profile>
        <id>integration-test</id>
        <properties>
            <build.profile.id>integration-test</build.profile.id>
            <skip.unit.tests>true</skip.unit.tests>
            <skipITs>false</skipITs>
        </properties>
    </profile>
    <profile>
        <activation>
            <os>
                <family>!windows</family>
            </os>
        </activation>
        <build>
            <plugins>

现在,我不包括整个 pom.xml。如果没有人能从我目前提供的内容中得到线索,我可能会这么做。

重要的部分是该清单的结尾。最后一个配置文件应该只在操作系统不是 Windows 时激活。我在 Windows 上工作,与我一起工作的另一个开发人员也在 Windows 上工作。我们还有许多其他开发人员在 Windows 和 Mac 上工作,但是 Windows 上的一位开发人员遇到了这个 pom.xml 的问题。

当我使用它运行构建时,它正确地不执行该激活块中的插件,因为我在 Windows 上。当其他开发人员执行此操作时,我们已经尝试使用 Maven 3.9.1 和 3.8.8(我正在使用 3.8.8 进行测试),它会执行该块中的插件,并因此失败(它指定了以下步骤)将无法在 Windows 上运行)。

我仔细研究了我和他的“mvn -X”输出(我还没有提供),我当然看到他的输出在哪里执行那些插件而我的没有,但我不知道查看任何明显的“决策点”,它评估该表达式并决定激活该配置文件。

我要找的是一些线索。我应该在他的输出和我的输出之间寻找什么?

更新

如果有帮助,enforcer 插件的输出显示在我们的“mvn -X”输出的顶部,所以我将在此处发布。他和我之间只有两个小区别。

我的:

Apache Maven 3.8.8 (4c87b05d9aedce574290d1acc98575ed5eb6cd39)
Maven home: ...\apache-maven-3.8.8
Java version: 11.0.13, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-11.0.13
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

他的:

Apache Maven 3.8.8 (4c87b05d9aedce574290d1acc98575ed5eb6cd39)
Maven home: ...\apache-maven-3.8.8
Java version: 11.0.18, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-11
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"

我们使用的 Java 11 补丁版本略有不同,出于某种原因,他的操作系统名称是“windows 11”,而我的是“windows 10”。其他一切都一样。

java maven
1个回答
0
投票

问题似乎是他的稍新版本的 JDK 实际上报告了正确的操作系统版本。根据 Java bug 报告 JDK-8274737 已在版本 11.0.13 中修复并包含在 release notes 但您出于某种原因使用的版本似乎不包含修复程序,它再次被提及Java 11.0.14 的发行说明。由于这是唯一明显的区别,您应该尝试使用较新版本的 Java 11。

© www.soinside.com 2019 - 2024. All rights reserved.