Repository Management with Nexus

4.2. Configuring Maven to Use a Single Nexus Group

If you are adopting Nexus for internal development you should configure a single Nexus group which contains both releases and snapshots. To do this, add snapshot repositories to your public group, and add the following mirror configuration to your Maven settings in ~/.m2/settings.xml.

Configuring Maven to Use a Single Nexus Group. 

      <!--This sends everything else to /public -->
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
    <!--make the profile active all the time -->

In Configuring Maven to Use a Single Nexus Group we have defined a single profile: nexus. It configures a repository and a pluginRepository with the id "central" that overrides the same repositories in the super pom. The super pom is internal to every Apache Maven install and establishes default values. These overrides are important since they change the repositories by enabling snapshots and replacing the URL with a bogus URL. This URL is overridden by the mirror setting in the same settings.xml file to point to the URL of your single Nexus group. This Nexus group can therefore contain release as well as snapshot artifacts and Maven will pick them up.

The mirrorOf pattern of * causes any repository request to be redirected to this mirror and therefore to your single repository group, which in the example is the public group.

It is possible to use other patterns in the mirrorOf field. A possible valuable setting is to use "external:*". This matches all repositories expect those using localhost or file based repositories. This is used in conjunction with a repository manager when you want to exclude redirecting repositories that are defined for integration testing. The integration test runs for Apache Maven itself require this setting.

More documentation about mirror settings can be found in the mini guide on the Maven web site.

As a last configuration nexus group is listed as an active profile in the activeProfiles element.