I have java application and deployed in a folder A. But I want to run mvn commands(mvn clean install) from folder B. Is that possible?
-
See the https://stackoverflow.com/a/4023629/3793078. using -f option (`mvn -f ../B/pom.xml`) – Yeongjun Kim Jan 28 '20 at 12:17
-
2Does this answer your question? [How to run Maven from another directory (without cd to project dir)?](https://stackoverflow.com/questions/6478536/how-to-run-maven-from-another-directory-without-cd-to-project-dir) – Julian Durchholz Jan 28 '20 at 12:17
-
Is it a multi maven structure? – Yeongjun Kim Jan 28 '20 at 12:19
2 Answers
Use the parameter -f then specify the path to your pom file, for example : mvn -f /path/to/pom.xml
This runs maven for the working directory.

- 314
- 1
- 13
If you want to build multiple projects, you can create a xml file like below and then use mvn clean install
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myProject</groupId>
<artifactId>full-build</artifactId>
<version>0.0.1</version>
<name>My Project Name</name>
<description>Full build of the Projects.</description>
<packaging>pom</packaging>
<modules>
<module>path of module 1</module>
<module>path of module 2</module>
<!-- You can even use relative path -->
<module>../folder1/relativePath/module 3</module>
</modules>
<dependencies>
// if any
</dependencies>
</project>

- 623
- 1
- 5
- 18