Title: How to generate an ear file from a maven-archetype-webapp artifact?
Tags: java;maven-2;web-applications;war;ear
Question: 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.  


Here is the accepted answer: 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.



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2010:00:05/15/10', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<java><maven-2><web-applications><war><ear>', 'Title': 'How to generate an ear file from a maven-archetype-webapp artifact?', 'ViewCount': 5277, 'id': 2838653, 'user_AboutMe': '<p>Uhm... yea...</p>\n\n<ul>\n<li><a href="http://myshittycode.com" rel="nofollow">My Shitty Code Blog</a></li>\n<li><a href="https://github.com/choonchernlim" rel="nofollow">My GitHub Page</a></li>\n</ul>\n', 'user_AccountId': 137377.0, 'user_DisplayName': 'limc', 'user_Reputation': 38606.0, 'user_Views': 2925.0, 'user_id': 341508.0}}