Importing a Maven War Module

I'm using a Maven project that I import with IntelliJ.  For the most part, Intellij seems to do a great job of keeping up with POM changes and updating dependencies.

One thing I noticed, however, is that maven does not have src/main/webapp in the classpath for unit tests (which I thought was a bit of a bummer).  I added


to the surefire plugin in maven.  It would be really awesome if Intellij would recognize that, and add it to the classpath as well.  It doesn't seem to do that in 9.0.1.

Has anyone else ran into this?  Being on a project where some people use Intellij and others use Eclipse, I'm trying to have instructions for folks to get up to speed that involve as little IDE specific steps as possible.  Has anyone else run into this?  Is the only fix to modify the module dependencies by hand?



If you add a directory via the <build><resources><resource><directory> element or the <build><testResources><testResource><directory> IDEA (and Maven) will pick them up as resources for the appropriate scope. Example:



        . . .


There is an old feature request requesting that IDEA take the additionalClasspathElements into account. I'd recommend voting for it and commenting on it to see if you can breath some new life into it.

IDEA-18512 Maven integration does not take additionalClasspathElements of surefire plugin into account


Thanks for the response.

This seems like a pretty reasonable idea, however, when I do this it seems to make Eclipse build the wrong WAR.  This, unfortunately, made all the Eclipse users on my team pretty unhappy.  They were no longer able to deploy in the IDE, so I had to revert this change.

Anyhow, that actually makes it a little more important to get the state bug fixed, since having a cross IDE team is probably a long term scenario for my group.


Out of curiosity, with the change in place, did maven itself (at the command line) build the wrong war? We're also a cross IDE team. What maven does at the command line is our guide line. 98% of the time, IDEA does exactly what maven does via the command line. The 2% of the time it doesn't are usually very fringe use cases. With Eclipse however, it's a 50/50 proposition. It seems our Eclipse users are constantly fighting the Eclipse Maven plug-in. I know Eclipse users don't want to hear it, and your team needs to be productive (and as an IDEA user you are likely in the minority), but IMHO Eclipse has the bigger issue here if it cannot handle the far more common change to the resource settings.

Anyways, hopefully we can get the above IDEA bug fixed.


Don't worry, will be fixed soon 8)


That's great news Anton. Thank.

@Will: I posted a comment in the IDEA-18512 bug report answering one of your other questions/comments.


This is exactly what I saw.

Maven worked fine.
Intellij worked fine.
Eclipse did not.


Please sign in to leave a comment.