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:
This topic shows you how to direct Maven to use the JBoss EAP 6 Maven Repository across all projects using the Maven settings. This is the recommended approach.
- You can modify the Maven settings. This directs Maven to use the configuration across all projects.
- You can configure the project's POM file. This limits the configuration to the specific project.
You can configure Maven to use either the online or a locally installed JBoss EAP 6 repository. If you choose to use the online repository, you can use a preconfigured settings file or add the JBoss EAP 6 Maven profiles to the existing settings file. To use a local repository, you must download the repository and configure the settings to point to your locally installed repository. The following procedures describe how to configure Maven for JBoss EAP 6.
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, see Section 2.2.2, “Install the JBoss EAP 6 Maven Repository”. 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 using either the Maven install global settings or the user install settings. These instructions configure the user install settings as this is the most common configuration.
Procedure 2.6. Configure Maven Using the Settings Shipped with the Quickstart Examples
The JBoss EAP 6 Quickstarts ship with a
settings.xml
file that is configured to use the online JBoss EAP 6 Maven repository. This is the simplest approach.
- This procedure overwrites the existing Maven settings file, so you must back up the existing Maven
settings.xml
file.- 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\
- If you have an existing
USER_HOME/.m2/settings.xml
file, rename it or make a backup copy so you can restore it later.
- Download and unzip the quickstart examples that ship with JBoss EAP 6. For more information, see Section 1.4.1.1, “Access the Quickstarts”
- Copy the
QUICKSTART_HOME/settings.xml
file to theUSER_HOME/.m2/
directory. - If you modify the
settings.xml
file while Red Hat JBoss Developer Studio is running, follow the procedure below entitled Refresh the Red Hat JBoss Developer Studio User Settings.
Procedure 2.7. Manually Edit and Configure the Maven Settings To Use the Online JBoss EAP 6 Maven Repository
You can manually add the JBoss EAP 6 profiles to an existing Maven settings file.
- 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\
- If you do not find a
settings.xml
file, copy thesettings.xml
file from theUSER_HOME/.m2/conf/
directory into theUSER_HOME/.m2/
directory. - 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 thesettings.xml
file.<activeProfile>jboss-ga-repository</activeProfile> <activeProfile>jboss-earlyaccess-repository</activeProfile>
- If you modify the
settings.xml
file while Red Hat JBoss Developer Studio is running, follow the procedure below entitled Refresh the Red Hat JBoss Developer Studio User Settings.
Procedure 2.8. Configure the Settings to Use a Locally Installed JBoss EAP Repository
You can modify the settings to use the JBoss EAP 6 repository installed on the local file system.
- 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\
- If you do not find a
settings.xml
file, copy thesettings.xml
file from theUSER_HOME/.m2/conf/
directory into theUSER_HOME/.m2/
directory. - Copy the following XML into the
<profiles>
element of thesettings.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 thesettings.xml
file.<activeProfile>jboss-eap-repository</activeProfile>
- If you modify the
settings.xml
file while Red Hat JBoss Developer Studio is running, follow the procedure below entitled Refresh the Red Hat JBoss Developer Studio User Settings.
Procedure 2.9. Refresh the Red Hat JBoss Developer Studio User Settings
If you modify the
settings.xml
file while Red Hat JBoss Developer Studio is running, you must refresh the user settings.
- From the menu, choose Window → Preferences.
- In the Preferences Window, expand Maven and choose User Settings.
- Click the Update Settings button to refresh the Maven user settings in Red Hat JBoss Developer Studio.
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:
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
- Missing artifact ARTIFACT_NAME
- [ERROR] Failed to execute goal on project PROJECT_NAME; Could not resolve dependencies for PROJECT_NAME
~/.m2/repository/
subdirectory on Linux, or the %SystemDrive%\Users\USERNAME\.m2\repository\
subdirectory on Windows.