JBoss.orgCommunity Documentation

Chapter 3. Creating a Maven Module

A Maven module is a sub-project. To create a Maven module you will need to already have a Maven project available.

The parent project must have its Packaging option pre-configured to pom, for a module to be created and associated with it. To ensure your parent project has this option set correctly before proceeding, double-click on the pom.xml file of your parent project in the Project Explorer.

In the Overview settings page that is now displayed in your workbench, confirm that the option Packaging is set to pom. If it is not, select pom from the list menu and save the changes to your pom.xml file.

The settings associated with the pom.xml file of the parent project.

Figure 3.1. Parent project pom.xml file settings


From your workspace navigate to FileNewOther and from the wizard selection screen select MavenMaven Module.

Wizard selection screen with the Maven Module wizard selected.

Figure 3.2. Selecting the Maven Module wizard


Type a name for the module in the Module Name field.

Typing a name for the module.

Figure 3.3. Naming the module


Click the Browse button beside the Parent Project field. This will launch a project selection box.

Select the project to be used as the parent project of the module you are creating, and click OK.

Selecting the project that will be the parent project of the module.

Figure 3.4. Selecting the parent project


You will be returned to the Select a parent project screen and the Parent Project field will contain the name of the project you selected.

The Select a parent project screen with the Parent Project field now containing the name of the selected project.

Figure 3.5. Parent Project field populated with project name


Click the Next button.

Select an archetype available in the list displayed. For the purposes of this example the maven-archetype-quickstart is selected.

Selecting an archetype for the module.

Figure 3.6. Archetype selection screen


Click the Next button.

Specify archetype parameters Group Id and Version. Ensure that the values you specify for these fields are unique from those set in the parent project.

In this example, the Group Id and Version settings of the parent project used are set to group_id and 0.0.1-SNAPSHOT respectively. For the module, Group Id and Version settings are being specified as sub_group_id and 0.1.1-SNAPSHOT respectively, to avoid conflict.

Specifying the settings to be used by the archetype for the module being created.

Figure 3.7. Archetype parameter settings


Click the Finish button.

The module will now be created and appear in your Project Explorer.

The module has now been created and appears in the Project Explorer.

Figure 3.8. Created module in the Project Explorer


You can view and change settings associated with the module by selecting the module's pom.xml file from the Project Explorer and double-clicking on it. This will launch an Overview screen containing the module settings.

The module Overview page, where settings can be viewed and changed.

Figure 3.9. Module Overview screen