Maven: How to use with IDEA

Maven: How to use with IDEA


This document provides the steps for opening and running your new project with IDEA.  It assumes you have already set up your Maven project from the command line, using these steps: Maven: How To Create a New Maven Project .

Step 1: Create New IDEA Project

From the home screen or the menu, select File > Open Project.  Navigate to the maven source code your archetype has created and select the root pom.xml file.  It will look like so:


This will do pretty much everything you need to build and configure your project.

Step 2: Download Your Dependencies

You can do this from the commandline or from your IDE.  From the commandline you can type this at the project root:

mvn dependency:sources

Then you would need to hit the Update Folders button in the Maven Projects tab, which you can expose by clicking on the Maven projects button along the right-hand side of the IDE:


Alternatively you can hit the Download Artifacts button to pull down and link up everything in one step.


Picture9.png Update Folders Use if you've run mvn dependency:sources on the commandline
Picture8.png Download Artifacts Use by itself; this can take a while and will tie up your IDE while everything downloads.

When this step is complete, the source code for all of your dependencies, including the application source will be on your machine, and available to you when you code and debug.

Test by looking up the LoginAction Java class.  You should see the full source code, not just the method signatures interpolated from the Jar.

Tips for Optimal Use

Avoid File Re-indexing

By default your plugin modules and web module will use the maven commandline output paths.  That means every time you build on the commandline with maven, IDEA will try to reindex all the files you delete and re-create.  Better to let IDEA maintain its own compile output, so select Inherit project compile output path as shown below in your Project Settings.