Java 在 mvn 命令中指定 pom.xml 并混合其他项目的目标

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4023597/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 08:37:06  来源:igfitidea点击:

specify pom.xml in mvn command and mix goals of other project

javamaven-2maven

提问by srinannapa

I have multiple questions.

我有多个问题。

  1. Can I specify the pom.xml in mvn command?
  2. Can I mix the goals of another project while executing mvn command on current project ?

    Eg: mvn clean-otherproject comple-otherproject instal-otherproject compile-thisproject

  1. 我可以在 mvn 命令中指定 pom.xml 吗?
  2. 在当前项目上执行 mvn 命令时,我可以混合另一个项目的目标吗?

    例如: mvn clean-otherproject comple-otherproject instal-otherproject compile-thisproject

I can do this with multiple mvn commands, but Can I do this in single maven command.

我可以用多个 mvn 命令来做到这一点,但我可以用单个 maven 命令来做到这一点。

采纳答案by khmarbaise

Just mvn --helpwould have answered the first question:

刚刚mvn --help会回答第一个问题:

 mvn -f otherPomFile.xml

No. You can simple execute the phases for the current project you are in. You can give multiple phases like

不。您可以简单地执行当前项目的阶段。您可以提供多个阶段,例如

mvn clean install site site:deploy

回答by Sean Patrick Floyd

For the first question, see khmarbaise's answer

第一个问题见khmarbaise的回答



If you want to build more than one maven project in one step, you must use modules.

如果你想一步构建多个maven项目,你必须使用modules

In a multi-module project, if you call mvn installfrom the top project, all sub modules are built, unless you use the advanced reactor options(e.g. mvn install -pl util -amonly builds the module 'util' and it's dependencies)

在多模块项目中,如果您mvn install从顶层项目调用,则会构建所有子模块,除非您使用高级反应器选项(例如,mvn install -pl util -am仅构建模块 'util' 及其依赖项)