How to add module compile output to web-inf/classes in stead of web-inf/lib?

I'm using maven to set up a war project in

IntelliJ
and run in it
GlassFish
. The war project depends on several other modules. When I run the project in debug mode, hot deploying codechanges of the changes results in
NoClassDefFound
exceptions. I found out that
IntelliJ
tries to redeploy the module jar but
GlassFish
keeps a lock on it so it fails. All the classes in that module are now unavailable, causing these
NoClassDefFound
exceptions.
IntelliJ
generates the artifacts this way: the dependent modules are all added as jar dependencies as if they were external dependencies:
automatic-artifacts.png
Now, when I remove the jar dependencies,
IntelliJ
tells me it found some missing dependencies and proposes a fix to add the missing dependencies.
Fixing those dependencies will add the module compile output to the
WEB-INF\classes
folder.
wanted-result.png

Once deployed,

IntelliJ
has no problem anymore hot-deploying changed classes to GlassFish since there's no jar to keep a lock on.

Problem

Every time I make a change to any

pom.xml
,
IntelliJ
refreshes the artifacts automatically, which is fine: I definitely want to see those changes appear in the artifact. However, all modules are added as
jar
dependencies again.

Question

How can I make sure that IntelliJ adds the compile output of project modules to

WEB-INF\classes
and not to
WEB-INF\lib
? (or: is there another way to avoid those 
NoClassDefFound
 errors?
I found this question but it has two problems:
  1. There are many module dependencies so if possible I'd like to avoid specifying them all one by one in the unpack goal
  2. IntelliJ
    seems to ignore this. When I add that configuration and while it works perfectly in a maven commandline build,
    IntelliJ
    still refuses to add the module compile output to the
    WEB-INF\classes
    dir

I found a bugreport that asks about the same thing but for me it's hard to believe there's no way to solve this problem. Other webapp developers using

IntelliJ
must have this same issue, making it difficult to hot-deploy code changes, unless I did something wrong in my
pom
configuration.

Please sign in to leave a comment.