Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using maven overlays in webapp run configuration using IntelliJ?

I am developing a magnolia based website. I am using the webapp archetype to create a new web application. Using the command line I am able to produce a WAR and deploy that in my container (Tomcat). I then run it and it works fine.

My next step was to import my project structure into IntelliJ. IntelliJ sees everything fine, and is able to compile it all. I have tested this by doing a maven clean first, and then let IntelliJ do the rest (rebuild project).

The last step is to let it run in my container. I have set up the run configurations before for web apps (they do not use war overlays), and they worked just fine. In this case I set it up just like before and point to my exploded webapp artifact.

Once I run tomcat, it does not find my webapp. I find that the overlay has not been merged into the target directory of the project (which normally is the case when just doing maven install). IntellJ however has created an overlays directory in my project and unpacked the (overlay/super) WAR file in there.

I get it working when I do a maven install myself, and then run Tomcat in IntelliJ. Which is obvious, because all sorts of needed files are now in my target directory (like a web.xml for example :)).

What I want is this: - IntelliJ knows that when it runs Tomcat, it should have prepared the target directory just like "mvn install" or "mvn package" would do.

What it does: - It does something in between. It does create a target dir, and it does copy resources from the webapp project. It does not overlay any WAR dependency, hence the webapp target dir is incomplete.

Anyone has any tips to solve this?

like image 682
Stefan Hendriks Avatar asked Sep 21 '11 09:09

Stefan Hendriks


1 Answers

I found that checking the "run maven goal" checkbox in the run configuration, and setting mvn package does make it work.

like image 100
Stefan Hendriks Avatar answered Nov 16 '22 01:11

Stefan Hendriks