Book Image

Apache Maven Cookbook

Book Image

Apache Maven Cookbook

Overview of this book

Table of Contents (18 chapters)
Apache Maven Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Building an EAR project


Maven provides support to generate Java EE Enterprise Archive (EAR) files. These can be deployed in application servers such as JBoss, WebLogic, and WebSphere.

How to do it...

  1. Run the following command from the command prompt:

    mvn archetype:generate -DgroupId=com.packt.cookbook -DartifactId=simple-ear -DarchetypeArtifactId=wildfly-javaee7-webapp-ear-archetype -DarchetypeGroupId=org.wildfly.archetype -DinteractiveMode=false
    
  2. Observe the result:

  3. Build the generated project:

    mvn clean package
    
  4. Observe the generated output:

  5. Open the target folder:

How it works...

We used the Maven Archetype plugin to bootstrap a simple EAR project. It generated a multi-module project, which has an EJB module, web module, and a EAR module along with the aggregate pom file. When you examine the pom file of the EAR module, you will notice that the packaging type is set to ear.

Once built, Maven builds all the modules. In the EAR module, it uses the packaging information to invoke the ear goal of the...