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:
console
as the parameters instead of $Prompt$
.
This will start Maven's console in a small pane inside IntelliJidea
(or idea:multiproject
) as the parameters.
Name this "Regenerate IntelliJ project". When run, it will regenerate all your IntelliJ projects, and
IntelliJ will prompt you to reload your project. For more information, see the
IntelliJ IDEA Plugin documentation.
$FileDir$
instead of $ProjectFileDir$
. This is useful
in a multiproject setup to run a specific goal on a particular module. In this case you should
select the "context menu" option instead of the "tools menu" option so that you can right-click on
a file in the navigation pane.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$:.* |