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”.
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:
- baseurl
- the base URL of the Nexus installation
- userId
- 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
<settings>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>${baseurl}/content/groups/public</url>
</mirror>
...
To preview a Maven Settings template, click on the Template URL in
the list. Clicking on this URL loads a dialog window which 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
- baseurl
- 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.
- password
- the password of the user
- userToken
- the formatted user token composed of name code, : and pass code.
- userToken.nameCode
- the name code part of the user token
- userToken.passCode
- the pass code part of the user token
- userToken.encrypted
- the encrypted, formatted user token
- userToken.nameCode.encrypted
- the encrypted name code part of the user token
- userToken.passCode.encrypted
- 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,
<server> <id>nexus</id> <username>$[username]</username> <password>$[password]</password> </server>
the usertoken equivalent
<server> <id>nexus</id> <!-- User-token: $[userToken] --> <username>$[userToken.nameCode]</username> <password>$[userToken.passCode]</password> </server>
or with
Maven
master-password encryption with the master keyword in
settings-security.xml:
<server> <id>nexus-client-side-interp-encrypted</id> <!-- User-token: $[userToken.encrypted] --> <username>$[userToken.nameCode.encrypted]</username> <password>$[userToken.passCode.encrypted]</password> </server>
The usage of the encrypted enwhich will result in values using the encrypted value syntax based on the master keyword similar to
<server>
<id>nexus-client-side-interp-encrypted</id>
<!-- User-token: {2Sn+...} -->
<username>{3HQg...}</username>
<password>{fsx2f...}</password>
</server>
Warning
userToken.* properties are only expanded to values if the
User Token feature as documented in Section 6.15, “Security Setup with User Tokens” is
enabled and configured.
