如何在Maven多模块项目中仅运行父pom.xml [英] how to run only parent pom.xml in maven multi-module project
问题描述
我有Maven多模块项目.在父级,我有一些Java文件.在父pom.xml中,在打包阶段我做了一些事情.
I have maven multi-modules project. At the parent level, i have some java files. And in the parent pom.xml, at the package phase i do some stuff.
通常,当我在父级别运行mvn package时,父pom的打包阶段将运行,并且所有模块也将被打包.
Usually, when i run mvn package at parent level, the package phase of parent pom will be run and all the modules will be packaged as well.
我正在寻找一种允许我执行这些操作的方式(当我运行mvn软件包时):
I am looking for a way that allow me to do these (when i run mvn package):
- 允许我仅运行paren pom.xml(位于打包阶段的脚本),而不运行模块.这是第一要务.
- 允许我运行paren pom.xml和某些特定模块(例如模块1,模块2但不是模块3,模块4).
我可以使用个人资料解决这些问题吗?
Can i use profile for those issue?
谢谢.
推荐答案
虽然我同意您可能没有最佳的项目结构这一事实,但答案是Maven 2.2.1具有选项"--non-recursive"满足您的第一个要求:
While I agree with the fact that you may not have optimal project structure, the answer is that Maven 2.2.1 has an option "--non-recursive" which satisfies your first requirement:
-N,--non-recursive Do not recurse into sub-projects
是这样的:
mvn --non-recursive clean compile
这篇关于如何在Maven多模块项目中仅运行父pom.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!