Repository Management with Nexus

13.2. Manage Maven Settings Templates

To manage Maven settings templates, click on Maven Settings in the Enterprise section of the Nexus menu on the left side of the Nexus UI. This will load the panel shown in Figure 13.1, “The Maven Settings Panel”.


Figure 13.1. The Maven Settings Panel

The Maven Settings panel allows you to add, delete, and edit Maven Settings templates. The default template has an ID of default and can not be changed. It contains the recommended settings for a standard Nexus installation. To create a new Maven settings template, click on the Add… button and select Settings Template. Once the new template is created, assign a name to the template in the Template ID text input and click the Save button.

To edit a template, click on a template that has a User Managed value of true in the list and edit the template in the tab below the list. Once you are finished editing the template, click Save to save the template. When editing the template you can insert some property references that will be replaced on the server with their values at request time:

The base URL of the Nexus installation.
The user id of the user that is generating a Maven Settings file from this template.

Server side interpolation takes effect even when the download of the settings template is done with tools like curl. These properties can be referenced in the settings file using the the syntax ${property}:


To preview a Maven settings template, click on the Template URL in the list. Clicking on this URL loads a dialog window that contains the Maven Settings file generated from this template. This rendered view of the Maven Settings template has all variable references replaced using the current context of the user. This is the result of running the property replacement on the Nexus server.

The Nexus M2Settings Maven Plugin supports the more powerful and feature-rich, client-side replacement of properties using a $[property] syntax.

Client-side properties supported by the Nexus M2Settings Maven Plugin are

The base URL of the Nexus installation.
userId or username
The username of the user that is requesting a Maven Settings file from this template.
The password of the user.
The formatted user token composed of name code, : and pass code.
The name code part of the user token.
The pass code part of the user token.
The encrypted, formatted user token.
The encrypted name code part of the user token.
The encrypted pass code part of the user token.

Client side interpolation allows you to fully populate a <server> section with the required properties either with the plain text username and password:


You can also use the the usertoken equivalent:

  <!-- User-token: $[userToken] -->

Alternatively you can use Maven master-password encryption with the master keyword in settings-security.xml:

  <!-- User-token: $[userToken.encrypted] -->

The usage of the .encrypted keys results in values using the encrypted value syntax based on the master keyword similar to the following snippet:

  <!-- User-token: {2Sn+...} -->

userToken.* properties are only expanded to values if the User Token feature as documented in Section 6.17, “Security Setup with User Tokens” is enabled and configured.