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

JavaMaven 2Maven

Java Problem Overview


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

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

Java Solutions


Solution 1 - Java

Just mvn --help would have answered the first question:

 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

Solution 2 - Java

For the first question, see khmarbaise's answer


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

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionsrinannapaView Question on Stackoverflow
Solution 1 - JavakhmarbaiseView Answer on Stackoverflow
Solution 2 - JavaSean Patrick FloydView Answer on Stackoverflow