Opening Maven Projects is Easy as Pie
Maven integration in a Java IDE might not be a surprise for you, but let me show you just one thing, that makes IntelliJ IDEA Maven support prominent and noteworthy.
If you have any Maven project, you do not need to perform routine steps while importing it to IntelliJ IDEA and you do not need to be anxious about dependencies and artifacts in it, nor would you need to worry about technologies used in project. Just open the project as you do with usual IntelliJ IDEA projects, sit back and relax. IntelliJ IDEA will automatically recognize everything.
Here is an example. To open our Maven project, we just go to 
IntelliJ IDEA creates a project based on the Maven Project descriptor file.
When done, all maven goals can be found in the Maven projects tool window. We can simply run/debug arbitrary Maven goals; execute them before/after make or run/debug, or by invoking an assigned keyboard shortcut. Select any Maven goal in the tree and right-click it to view options.
Now, let’s view our project structure. Go to 
That’s all, nothing but a single click and you can enjoy complete support for Maven builder, including smart coding assistance for editing Maven pom.xml, intelligent code completion, inspections and quick-fixes, refactorings and other IntelliJ IDEA productivity-boosting features, which we are going to cover in the next posts.
I work a lot with maven and Idea, works great, but I have one small question: is there a way to have Idea remember that the “target” folders are ignored, even when I do a “mvn clean” via the command line ? Usually, doing this just kills the “ignore” settings and I have to go through the Project settings > modules > set target folders to ignore all over again
Unfortunatelly we cannot exclude target directory since it may contain generated sources. All the directories under the target are exluded, though.
The 8.0 eap and forthcoming 7.0.4 eap feature improved handling of target directory. You may try them both.
I don’t understand why the maven plugin doesn’t inform IntelliJ of where it is putting the dependencies. When I go to the dependency tab all the jars are red and cannot be edited (the edit button does nothing and the navigate right-click option is greyed out). I have to manually find them and add them to my global library to do any real work.
All the dependencies are resolved and downloaded during importing and are put in the maven’s repository (by default in ~/.m2). If you have ‘red’ dependencies, it must be something wrong with either pom or repository.
You may write me on ‘Anton dot Makeev at jetbrains dot com’ and describe you problem in details.
they are downloaded and placed in your repository but those dependencies are not placed into IntelliJ’s global libraries
so you can build a Maven project and run through its goals without issue but to properly develop an application further you need to manually build your global library based on where Maven put those dependencies in your repository or copy the source’s application library config file
~/.IntelliJIdea70/config/options/applicationLibraries.xml
this is not an optimal solution
Maven dependencies are not supposed to be placed into any global library: they are configured as module libraries. Could you send me your pom file and some screenshots on \’Anton dot Makeev at jetbrains dot com’ so I could understand the problem?
I really like the pom support in Idea, but I’m having trouble with HotSwap in the debugger. When I compile just a single file (ctrl + shift + F9), it appears to be running a maven target, which triggers a reload of my webapp. I really want to just compile the file and have it HotSwap without triggering anything from Maven. Is this possible?
Thanks!
Darin
I don’t quite understand you.
Do you want to automatically run hotswap after executin maven goal?
If it’s so you may vote for and watch http://www.jetbrains.net/jira/browse/IDEADEV-26044.
We’ll implement it in one of the following eaps.
I don’t want to run hotswap after executing a maven goal, I want to be able to compile a single file and hotswap it without running any maven goals. For example, say that I run “maven package” to build a .war file and start my app server. Then I make a change to a java file. I’d like to compile that single file in Idea and have it hotswap. Currently, when I run “Compile Foo.java (ctrl+shift+F9)” it runs a maven goal that regenerates the war file instead of just compiling the single file and hotswapping it. The problem is that redeploying the war file is too slow and doesn’t always work (and defeats the purpose of hotswap.)
I used to do this exact behavior, when using running “mvn idea:idea” and having maven generate my project/module files. For some reason, when I switched over to using the pom as the project file, I lost this functionality. Otherwise, I prefer using the pom support, so I’m hoping it is possible to hotswap a single file without running maven targets.
Compilation with SHIFT+CTRL+F9 does not run maven goal: it runs the native idea compilation process; this process involves regeneration of the war file, though.
I could recommend you to use an exploded directory instead of the war if you want to have a quick hatswap.
If you want any details, please mail me to Anton dot Makeev at jetbrains dot com.
I am having trouble debugging maven goals. I can run individual goals by double-clicking them or by selecting “Run Goal” from the context menu. However, if I select “Run ‘project_name [goal_name]’” or “Debug ‘project_name [goal_name]’” from the context menu, I get an error “Error running Tests: No valid Maven installation found. Either set the home directory in the configuration dialog or set the M2_HOME environment variable on your system.” I have set the home directory on the configuration dialog. Can you give me any other pointers?
Unfortunately at the moment you have to specify an installation path for the Maven Run Configuration itself: the Maven Settings do not affect Run Configurations.
This inconsistency will be fixed in next versions.