2.3.2. Configure the JBoss EAP 6 Maven Repository Using the Maven Settings

There are two approaches to direct Maven to use the JBoss EAP 6 Maven Repository in your project:
  • You can modify the Maven settings.
  • You can configure the project's POM file.
This task shows you how to direct Maven to use the JBoss EAP 6 Maven Repository across all projects using the Maven global or user settings. This is the recommended approach.

Note

The URL of the repository will depend on where the repository is located; on the filesystem, or web server. For information on how to install the repository, refer to the chapter entitled Maven Guide in the Development Guide for JBoss EAP 6 on https://access.redhat.com/site/documentation/JBoss_Enterprise_Application_Platform/. The following are examples for each of the installation options:
File System
file:///path/to/repo/jboss-eap-6.x-maven-repository
Apache Web Server
http://intranet.acme.com/jboss-eap-6.x-maven-repository/
Nexus Repository Manager
https://intranet.acme.com/nexus/content/repositories/jboss-eap-6.x-maven-repository
You can configure Maven to use the JBoss EAP 6 Repository using either the Maven install or the user install settings. For more information about the location of the settings and how they behave, refer to the chapter entitled Maven Guide in the Development Guide for JBoss EAP 6 on https://access.redhat.com/site/documentation/JBoss_Enterprise_Application_Platform/. .
To use the JBoss EAP 6 repository on a local user system, follow these instructions:

Procedure 2.6. Configure the Settings

  1. Open the settings.xml for the type of configuration you have chosen.
    • Global Settings

      If you are configuring the global settings, open the M2_HOME/conf/settings.xml file.
    • User Settings

      If you are configuring user specific settings and you do not yet have a USER_HOME/.m2/settings.xml file, copy the settings.xml file from the M2_HOME/conf/ directory into the USER_HOME/.m2/ directory.
  2. Copy the following XML into the <profiles> element of the settings.xml file. Be sure to change the <url> to the actual repository location.
    
    <profile>
      <id>jboss-eap-repository</id>
      <repositories>
        <repository>
          <id>jboss-eap-repository</id>
          <name>JBoss EAP Maven Repository</name>
          <url>file:///path/to/repo/jboss-eap-6.x-maven-repository</url>
          <layout>default</layout>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
          </releases>
          <snapshots>
            <enabled>false</enabled>
            <updatePolicy>never</updatePolicy>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>jboss-eap-repository-group</id>
          <name>JBoss EAP Maven Repository</name>
          <url>
          file:///path/to/repo/jboss-eap-6.x-maven-repository
          </url>
          <layout>default</layout>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
          </releases>
          <snapshots>
            <enabled>false</enabled>
            <updatePolicy>never</updatePolicy>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
    
    
    Copy the following XML into the <activeProfiles> element of the settings.xml file.
    
    <activeProfile>jboss-eap-repository</activeProfile>
    
    
    
  3. If you modify the settings.xml file while JBoss Developer Studio is running, you must refresh the user settings. From the menu, choose WindowPreferences. In the Preferences Window, expand Maven and choose User Settings. Click the Update Settings button to refresh the Maven user settings in JBoss Developer Studio.
    Update Maven User Settings

    Figure 2.1. Update Maven User Settings

Important

If your Maven repository contains outdated artifacts, you may encounter one of the following Maven error messages when you build or deploy your project:
  • Missing artifact ARTIFACT_NAME
  • [ERROR] Failed to execute goal on project PROJECT_NAME; Could not resolve dependencies for PROJECT_NAME
To resolve the issue, delete the cached version of your local repository to force a download of the latest Maven artifacts. The cached repository is located in your ~/.m2/repository/ subdirectory on Linux, or the %SystemDrive%\Users\USERNAME\.m2\repository\ subdirectory on Windows.
Result

The JBoss EAP 6 repository has now been configured.