Maven 配置文件激活失败
Maven profile file activation fails
我有一个父 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 构建,构建也会失败。
为什么在 eclipse 中构建 运行 而在命令行中不构建?为什么不遵守 common-build
的父 pom 中的配置文件定义?
经过进一步测试,我找到了解决方案。构建失败,因为配置文件激活的文件夹丢失了。我已将项目添加到 git 并忘记了 git 不会 commit/push 空文件夹。
解决方案是在文件夹中添加一个空 .gitkeep
以强制 git 到 commit/push 它们。
我有一个父 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 构建,构建也会失败。
为什么在 eclipse 中构建 运行 而在命令行中不构建?为什么不遵守 common-build
的父 pom 中的配置文件定义?
经过进一步测试,我找到了解决方案。构建失败,因为配置文件激活的文件夹丢失了。我已将项目添加到 git 并忘记了 git 不会 commit/push 空文件夹。
解决方案是在文件夹中添加一个空 .gitkeep
以强制 git 到 commit/push 它们。