【发布时间】:2018-02-08 10:16:28
【问题描述】:
我有一个父 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 中的配置文件定义不被尊重?
【问题讨论】:
-
你好,你能用
${project.basedir}代替${basedir}吗? -
运行
mvn -X ...可能会在这种情况下提供洞察力。
标签: maven maven-profiles