Maven 聚合 POM 与目标?
我有一个聚合了多个模块的 Maven POM。
<project [stuff]>
<modelVersion>4.0.0</modelVersion>
<groupId>com.fuhu.osg</groupId>
<artifactId>UserManagement</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<name>UserManagement</name>
<modules>
<module>core</module>
<module>war</module>
<module>ejbs</module>
<module>ear</module>
</modules>
</project>
我想要执行一个不适用于顶级 POM 模块的目标。类似于mvn db-migrate:create。事实上,这似乎试图针对子项目运行上述命令,这对于其他所有目标都是正确的,但对于这个目标则不然。
有没有办法让 Maven POM 既是某些目标的聚合,又是其他目标的普通项目?
I have a Maven POM that aggregates several modules.
<project [stuff]>
<modelVersion>4.0.0</modelVersion>
<groupId>com.fuhu.osg</groupId>
<artifactId>UserManagement</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<name>UserManagement</name>
<modules>
<module>core</module>
<module>war</module>
<module>ejbs</module>
<module>ear</module>
</modules>
</project>
I want to execute a goal that doesn't apply to the modules against the top-level POM. Something like mvn db-migrate:create. As is, it seems like this attempts to run said command against the sub-projects, which is correct for every OTHER goal, but not for this one.
Is there a way to make a Maven POM that is both an Aggregate for some goals and an ordinary project for others?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Maven 构建配置文件可能会对您有所帮助。在使用某一配置文件时,可以轻松配置要调用的一个子模块。
http://maven.apache.org/guides/introduction/introduction-to -profiles.html
使用 db 配置文件启动您的 db 任务,如下所示:
使用系统环境等可以自动激活配置文件。遗憾的是,我找不到命令行目标的 Maven 属性,这将启用自动当该特定目标运行时激活配置文件。
You might be helped by Maven build profiles. It's easy to configure one submodule to be invoked when using a certain profile.
http://maven.apache.org/guides/introduction/introduction-to-profiles.html
Start your db task with the db profile with something like:
Auto activation of profiles is possible using system environment etc. Sadly I can't find a maven property for the command line goal, which would enable auto activation of a profile when that specific goal is run.