[英]how to run only parent pom.xml in maven multi-module project
I have maven multi-modules project.我有 maven 多模块项目。 At the parent level, i have some java files.在父级,我有一些 java 文件。 And in the parent pom.xml, at the package phase i do some stuff.在父 pom.xml 中,在打包阶段我做了一些事情。
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 package 时,父 pom 的 package 阶段将被运行并且所有模块也将被打包。
I am looking for a way that allow me to do these (when i run mvn package):我正在寻找一种允许我执行这些操作的方法(当我运行 mvn 包时):
Can i use profile for those issue?我可以对这些问题使用配置文件吗?
Thanks.谢谢。
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:虽然我同意您可能没有最佳项目结构的事实,但答案是 Maven 2.2.1 有一个选项“--non-recursive”满足您的第一个要求:
-N,--non-recursive Do not recurse into sub-projects
So something like this:所以像这样:
mvn --non-recursive clean compile
Why do you want to have java code on the top level?为什么要在顶级有java代码? In my opinion this is not a very good idea.在我看来,这不是一个好主意。 Have your code in the subprojects and let the top-level project be responsible for holding the general information and configuration of the entire project.把你的代码放在子项目中,让顶级项目负责保存整个项目的一般信息和配置。
If you have some base-library code in the top-level project now, you can put it in a sub-project and set up dependencies between the projects.如果你现在在顶级项目中有一些基础库代码,你可以把它放在一个子项目中,并设置项目之间的依赖关系。
Take a look at Maven parent pom vs modules pom看看Maven 父 pom 与模块 pom
The nature of your question indicates that your project structure may not be optimal.您问题的性质表明您的项目结构可能不是最佳的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.