views:

329

answers:

1

I currently have a project built with maven-archetype-webapp artifact. The default packaging for this project is war.

Is it possible for me to insert the maven-ear-plugin in this webapp pom.xml generate an ear file that contains this project war? I tried that, but the war file doesn't get embedded in the generated ear file. It has everything except the war file.

I read many Maven related articles, and perhaps I could use maven-archetype-j2ee-simple artifact. However, I'm reluctant to this use for 2 reasons:-

  • This artifact handles ejbs and all the extra features that I don't use. It makes my project looks bloated.
  • Second, it seems like it requires me to install the web module into the repository first before I can create the ear file. Is this the preferred way to create an ear file?

How do I create an ear file that contains the war file using maven-ear-plugin from my webapp's pom.xml? If this way is not possible, what's the preferred way?

I'm sorry if my questions sound a little novice, I realized I have whole lot more to learn about Maven.

Thanks much.

+1  A: 

The maven ear plugin assumes that any WAR is a separate project, so you need two projects, plus a parent project. It's a function of how maven does packaging. Each project produces one artifact. There are ways around this, but Maven will punish you for your sins. This question goes into some detail on this topic.

sblundy
+1 good reference :)
Pascal Thivent