macosmavenintellij-ideaconfig

How to use IntelliJ bundled maven in terminal?


Using MacOS Catalina. Installed IntelliJ. Maven works fine but in terminal mvn comand is not found. How to use IntelliJs maven in terminal?


Solution

  • Locating mvn installed using IntelliJ

    If you are specifically looking for mvn location, installed using IntelliJ on MacOS: /Applications/IntelliJ IDEA CE.app/Contents/plugins/maven/lib/mvn


    Executing mvn from terminal

    Now, if you want to execute mvn from terminal, you need to add to your path.

    Assuming that you'are using zshrc, which is my case, you'll need to add the following command to ~/.zshrc

    export PATH="$PATH:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin"
    

    Now, reopen your terminal, and you can call mvn.

    Obs.: Thanks to nbro's answer


    Solving "Permission Denied"

    If you try to execute mvn and get "Permission Denied", you need to give execution permission:

    chmod +x "/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin/mvn"