How to create ear file from maven-archetype-webapp artifact?

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

Is it possible for me to embed the maven-ear-plugin in this webapp pom.xml creating an ear file that contains this project war? I tried this, but the war file is not embedded in the generated ear file. It has everything except the military file.

I've read a lot of Maven related articles and maybe I could use the maven-archetype-j2ee-simple artifact. However, I don't want to use this for two reasons: -

  • This artifact handles ejbs and all additional features that I am not using. This makes my project look bloated.
  • Second, I feel like I need 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 containing a war file using the maven-ear-plugin from my webapp pom.xml? If this way is not possible, what is the preferred way?

I am sorry if my questions sound a bit newbie, I realized that I need to learn a lot more about Maven.

Thank you very much.

+2


a source to share


1 answer


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



+3


a source







All Articles