4.2.4.2. Configure the Maven Settings for Use with Command Line

The artifacts and dependencies needed to build and deploy applications to JBoss EAP 6 are hosted on a public repository. If you plan to use JBoss Developer Studio to build and deploy applications, you can skip this topic. Instead, follow the instructions here: Section 4.2.3.1, “Configure Maven for Use with JBoss Developer Studio”. However, if you plan to use Maven command line, you must direct Maven to use the JBoss EAP 6 Maven Repository across your projects using the Maven settings.
There are 2 ways to configure the settings for use with Maven command line.
  • You can copy the preconfigured settings.xml file that ships with the quickstarts.
  • You can manually edit the Maven settings.xml file.
This topic describes both methods. If you have downloaded the quickstarts, the first procedure is the simplest way to configure the settings.
Prerequisites

You must install Maven before you configure the settings. For more information, see: Section 4.2.4.1, “Download and Install Maven”

Procedure 4.5. Configure Maven Using the Settings Shipped with the Quickstart Examples

The Red Hat JBoss Enterprise Application Platform Quickstarts ship with a settings.xml file that is configured to use the online JBoss EAP Maven repository. If you have downloaded the quickstarts, this is the easiest way to configure the settings.
  1. This procedure overwrites the existing Maven settings file, so you must back up the existing Maven settings.xml file.
    1. Locate the Maven install directory for your operating system. It is usually installed in USER_HOME/.m2/ directory.
      • For Linux or Mac, this is: ~/.m2/
      • For Windows, this is: \Documents and Settings\USER_NAME\.m2\ or \Users\USER_NAME\.m2\
    2. If you have an existing USER_HOME/.m2/settings.xml file, rename it or make a backup copy so you can restore it later.
  2. If have not yet downloaded the quickstarts, follow the instructions here: Section 3.4.1, “Download the Quickstarts”.
  3. Copy the QUICKSTART_HOME/settings.xml file to the USER_HOME/.m2/ directory.
  4. If you modify the settings.xml file while JBoss Developer Studio is running, follow the procedure at the end of this topic entitled Refresh the JBoss Developer Studio User Settings.

Procedure 4.6. Manually Edit and Configure the Maven Settings To Use the Online JBoss EAP Maven Repository

You can manually add the JBoss EAP profiles to an existing Maven settings file.
  1. Locate the Maven install directory for your operating system. It is usually installed in USER_HOME/.m2/ directory.
    • For Linux or Mac, this is ~/.m2/
    • For Windows, this is \Documents and Settings\USER_NAME\.m2\ or \Users\USER_NAME\.m2\
  2. If you do not find a settings.xml file, copy the settings.xml file from the USER_HOME/.m2/conf/ directory into the USER_HOME/.m2/ directory.
  3. Copy the following XML into the <profiles> element of the file.
    <!-- Configure the JBoss GA Maven repository -->
    <profile>
      <id>jboss-ga-repository</id>
      <repositories>
        <repository>
          <id>jboss-ga-repository</id>
          <url>http://maven.repository.redhat.com/techpreview/all</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>jboss-ga-plugin-repository</id>
          <url>http://maven.repository.redhat.com/techpreview/all</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
    <!-- Configure the JBoss Early Access Maven repository -->
    <profile>
      <id>jboss-earlyaccess-repository</id>
      <repositories>
        <repository>
          <id>jboss-earlyaccess-repository</id>
          <url>http://maven.repository.redhat.com/earlyaccess/all/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>jboss-earlyaccess-plugin-repository</id>
          <url>http://maven.repository.redhat.com/earlyaccess/all/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
    
    
    Copy the following XML into the <activeProfiles> element of the settings.xml file.
    <activeProfile>jboss-ga-repository</activeProfile>
    <activeProfile>jboss-earlyaccess-repository</activeProfile>
    
    
  4. If you modify the settings.xml file while JBoss Developer Studio is running, follow the procedure at the end of this topic entitled Refresh the JBoss Developer Studio User Settings.

Procedure 4.7. Refresh the JBoss Developer Studio User Settings

If you modify the settings.xml file while JBoss Developer Studio is running, you must refresh the user settings.
  1. From the menu, choose WindowPreferences.
  2. In the Preferences Window, expand Maven and choose User Settings.
  3. Click the Update Settings button to refresh the Maven user settings in JBoss Developer Studio.
    Update Maven User Settings

    Figure 4.15. 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.