Using Maven in IntelliJ IDEA Brett Porter

The recommended way to integrate Maven into your IntelliJ IDEA, is to use the MevenIDE for IDEA plugin. It will allow you to execute goals from within the IDE, visually edit the POM (project.xml) file, select favorite and common goals for each module, etc. The MevenIDE for IDEA project is still young, but provides most of the basic tools you will need to use Maven from IntelliJ.

Alternatively, you can configure it as an external tool, which allows you to define command lines that execute Maven with customizable parameters. To add Maven as an external tool in IntelliJ IDEA 4.0+, open the IDE settings, and click the "External Tools" button. From there, press "Add..." to open a new dialog. The following settings should be used:

Name: Maven (prompt)
Group: Maven
Description: Run Maven, prompting me for the goals to run
Program: select maven.bat or maven from the MAVEN_HOME/bin directory using the file browser
Parameters: $Prompt$
Working Directory: $ProjectFileDir$

When selected from the tools menu, this will prompt you for the goals to run, and run it from the main project directory.

There are other tools you might like to set up in a similar fashion. You can quickly do this by pressing the "Copy..." button and renaming the new tool. Here are some examples:

Finally, you might like to set up an output filter. In the external tools dialog, press the "Output Filters..." button, and use the following settings:

Name: Maven error link
Description: Highlight the error of the maven compile goal
Regular expression to match output: $FILE_PATH$:$LINE$:.*