Red Hat Training

A Red Hat training course is available for Red Hat Fuse

6.3. Configure Maven to Use the Online Repositories

The online repositories required for Red Hat JBoss Fuse applications are located at http://maven.repository.redhat.com/techpreview/all/ and http://repository.jboss.org/nexus/content/repositories/public/.
If you provided the location of Maven's settings.xml file during installation, Maven is already configured to use the online repositories. If you did not provide the location during installation, you need to configure Maven manually by following the procedure in Section 6.3, “Configure Maven to Use the Online Repositories”.
If you did not configure the Maven repository during installation, you can configure it using the following procedure. (It is also possible to do this using the project's POM file, but this is not recommended.)

Procedure 6.1. Configuring Maven to Use the Online Repositories

  1. Add entries for the online repositories to Maven's settings.xml file as in the code sample below:
    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    
      <profiles>
        <!-- Profile with online repositories required by Fuse -->
        <profile>
          <id>fsw-online-repos</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>
            <repository>
              <id>jboss-public-repository</id>
              <url>http://repository.jboss.org/nexus/content/repositories/public/</url>
              <releases>
                <enabled>true</enabled>
              </releases>
              <snapshots>
                <enabled>false</enabled>
              </snapshots>
            </repository>
            <repository>
              <id>jboss-fuse-public-repository</id>
              <url>https://repo.fusesource.com/nexus/content/groups/public/</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>
            <pluginRepository>
              <id>jboss-public-plugin-repository</id>
              <url>http://repository.jboss.org/nexus/content/repositories/public/</url>
              <releases>
                <enabled>true</enabled>
              </releases>
              <snapshots>
                <enabled>false</enabled>
              </snapshots>
            </pluginRepository>
            <pluginRepository>
              <id>jboss-fuse-public-plugin-repository</id>
              <url>https://repo.fusesource.com/nexus/content/groups/public/</url>
              <releases>
                <enabled>true</enabled>
              </releases>
              <snapshots>
                <enabled>false</enabled>
              </snapshots>
            </pluginRepository>
          </pluginRepositories>
        </profile>    
      </profiles>
    
      <activeProfiles>
        <!-- Activation of the Fuse profile -->
        <activeProfile>fsw-online-repos</activeProfile>
      </activeProfiles>
    
    </settings>
  2. If you modified the settings.xml file while JBoss Developer Studio was running, you must refresh Maven settings in the IDE. 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.

    Figure 6.1. Update Maven User Settings

    Update Maven User Settings

Result

Maven has been configured to use the online repositories provided for Red Hat JBoss Fuse.

Important
If your cached local Maven repository contains outdated artifacts, you may encounter one of the following Maven errors 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 local repository - the ~/.m2/repository/ directory on Linux or the %SystemDrive%\Users\USERNAME\.m2\repository\ directory on Windows. This will force Maven to download correct versions of required artifacts during the next build.