Maven Getting Started - Developers

This page provides information for JBoss developers to get started with using the JBoss Maven repositories.

 

If you are new to Maven, you may want to first go to the Apache Maven site to learn the basics (http://maven.apache.org/).  If you are already familiar with Maven, and want to learn how to use the JBoss Maven repositories in your builds, you are in the right place.

 

Overview

For an overview of how the JBoss Maven repository is organized, see the wiki page Maven Repository.

 

Configuring Maven to use the JBoss Repository

When developing JBoss projects, it is important that all project dependencies are available via the JBoss repository.  In order for your build to use artifacts from the JBoss Maven repository and to save artifacts from remote repositories, you will need to configure your build to use the public repository group which will automatically include several remote repositories.  The following repository configuration should be added to your project POM.

 

 

<repositories>
    <repository>
      <id>jboss-public-repository-group</id>
      <name>JBoss Public Repository Group</name>
      <url>http://repository.jboss.org/nexus/content/groups/public/</url>
      <layout>default</layout>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </snapshots>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <id>jboss-public-repository-group</id>
      <name>JBoss Public Repository Group</name>
      <url>http://repository.jboss.org/nexus/content/groups/public/</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>

 

 

Alternatively, the above configuration can be put into a profile in your user settings file (~/.m2/settings.xml)

 

To deploy to the repository, you will need to add your JBoss.org credentials to your settings.  The following snippet from settings.xml shows what you need to deploy to the JBoss repositories.

 

 

<settings>
  ...
  <servers>
    <server>
      <id>jboss-snapshots-repository</id>
      <username>jboss.org username</username>
      <password>jboss.org password</password>
    </server>
    <server>
      <id>jboss-releases-repository</id>
      <username>jboss.org username</username>
      <password>jboss.org password</password>
    </server>
  </servers>
  ...
</settings>

 

This mirror setting will force Maven to use only a single URL for all dependency downloads.  Your username and password must be specified three times, one for each of (1) the repository group URL, (2) deployment to the snapshot repository, and (3) deployment to the releases repository.  Unfortunately, Maven does not currently have a proper way to assign multiple repository to the same credential information.

 

Using Deprecated Artifacts

 

The JBoss Maven repository has been reorganized to provide a cleaner and more flexible repository.  During this process many artifacts were moved to a deprecated repository.  If your build needs to continue to use these deprecated artifacts during the migration process, you can enable this repository using a profile.

 

 

    <profile>
      <id>jboss-deprecated</id>
      <repositories>
        <repository>
          <id>jboss-deprecated</id>
          <name>JBoss Deprecated</name>
          <url>https://repository.jboss.org/nexus/content/repositories/deprecated/</url>
          <layout>default</layout>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
      </repositories>
    </profile>

 

More info about the deprecated repository here ( JBoss Deprecated Repository ).

 

(Optional) Using Additional Repositories

 

Your build may need to search additional repositories for certain builds.  For example, the maven2-brew repository (http://repository.jboss.org/maven2-brew).  This can be done with a minor change to the mirror settings, and adding the repository to a profile.

 

First add a profile that will add the repository to your builds.

 

 

    <profile>
      <id>jboss-maven2-brew</id>
      <repositories>
        <repository>
          <id>jboss-maven2-brew</id>
          <name>JBoss Maven 2 Brew Repository</name>
          <url>http://repository.jboss.org/maven2-brew/</url>
          <layout>default</layout>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
      </repositories>
    </profile>

 

This profile can be made active automatically by adding it to <activeProfiles>

(Optional) Mirror Settings

 

Another option is to put the public repository into a mirror configuration in your settings.xml.  This will force Maven to download only from certain repositories.

 

The mirror settings would look something like this.

 

 

    <mirror>
      <id>jboss-public-repository-group</id>
      <mirrorOf>*,!jboss-deprecated,!jboss-maven2-brew</mirrorOf>
      <name>JBoss.org Public Repository Group</name>
      <url>http://repository.jboss.org/nexus/content/groups/public/</url>
    </mirror>

 

 

(Optional) Using JBoss Maven Plugins

 

Several JBoss projects include Maven plugins.  You can add configuration to your settings.xml which will allow Maven to use shorthand notation when referring to these plugins.

 

 

  <pluginGroups>
    <pluginGroup>org.jboss.maven.plugins</pluginGroup>
  </pluginGroups>

 

Example Settings

 

A complete example of settings.xml is also available ( Maven Settings Example - Developers ).

 

 

Deploying Projects to the Repository

 

You project pom.xml must be configured with the correct distributionManagement information in order to deploy to the repository.  There are several deployment scenarios in the normal development process.

 

Maven Deploying a Snapshot

 

Maven Deploying a Release

 

Uploading a Thirdparty Artifact

 

 

 

Using Thirdparty Maven Repositories

 

The JBoss repository will automatically proxy artifacts from several thirdparty repositories.  The current list of proxy repositories can be seen by logging in to the Nexus interface ( https://repository.jboss.org/nexus ).

 

If you would like to request additional thirdparty repositories to be proxied, please create a jira issue under the JBBUILD project.

 

.