maven

How to run Maven from another directory (without cd to project dir)?


Supposing my maven project is located in /some/location/project and my current location is /another/location/ how can I run maven build without changing to project location cd /some/location/project?


Solution

  • You can use the parameter -f (or --file) and specify the path to your pom file, e.g. mvn -f /path/to/pom.xml

    This runs maven "as if" it were in /path/to for the working directory.