Maven配置文件激活失败



i有一个父pom,该pom定义了应激活的配置文件,当存在定义的文件夹时:

<groupId>common</groupId>
<artifactId>common-build</artifactId>
<profiles>
    <profile>
        <id>dependency-profile-ejb</id>
        <activation>
            <file>
                <exists>${basedir}/src/profile/dependency-ejb/</exists>
            </file>
        </activation>
        <dependencies>[...]</dependencies>
    </profile>
    <profile>
        <id>dependency-profile-jsf</id>
        <activation>
            <file>
                <exists>${basedir}/src/profile/dependency-jsf/</exists>
            </file>
        </activation>
        <dependencies>[...]</dependencies>
    </profile>
</profiles>

我有一个带有几个子模型的Maven项目:

<parent>
    <groupId>common</groupId>
    <artifactId>common-build</artifactId>
</parent>
<groupId>project/groupId>
<artifactId>project-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<modules>
    <module>project-child-one<module>
</modules>

在儿童项目中,我只是定义了父母的依赖性:

<parent>
    <groupId>project</groupId>
    <artifactId>project-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>project-child-one</artifactId>

,在这个孩子项目中,我定义了文件夹src/profile/dependency-ejb

如果我在Eclipse中运行项目的构建,则一切都按预期运行。然后,我在詹金斯(Jenkins(安装了该项目,但是构建失败了。如果我将project-parent检查到干净的目录中并尝试运行Maven构建,则构建也会失败。

为什么构建在日食中运行而不是在命令行中运行?为什么在common-build的父poM中的概况定义不尊重?

在进行一些进一步的测试之后,我找到了解决方案。构建失败了,因为缺少轮廓激活的文件夹。我添加了该项目以git,并忘记了git不提交/推出空文件夹。

解决方案是在文件夹中添加一个空的.gitkeep,以强迫Git提交/推动它们。

最新更新