To manage Nexus repositories, log in as the administrative user and click on Repositories in the Views/Repositories menu in the left-hand Nexus menu.
Nexus provides for three different kinds of repositories: Proxy Repositories, Hosted repositories, and Virtual repositories.
A Proxy Repository is a proxy of a remote repository. By default, Nexus ships with the following configured proxy repositories:
- Apache Snapshots
- This repository contains snapshot releases from the Apache Software Foundation.
- Codehaus Snapshots
- This repository contains snapshot releases from Codehaus.
- This is the Central Repository containing release artifacts. Formerly known as Maven Central, it is the default built-in repository for Apache Maven and directly supported in other build tools like Gradle, SBT or Ant/Ivy. For Nexus OSS, the URL http://repo1.maven.org/maven2/ is used, while Nexus Professional has the SSL secured version https://secure.central.sonatype.com/maven2/ preconfigured. Nexus OSS users and users of other repository managers can purchase usage of the secured version for a nominal fee.
A Hosted Repository is a repository that is hosted by Nexus. Nexus ships with the following configured hosted repositories:
- 3rd Party
- This hosted repository should be used for third-party dependencies not available in the public Maven repositories. Examples of these dependencies could be commercial, proprietary libraries such as an Oracle JDBC driver that may be referenced by your organization.
- This hosted repository is where your organization will publish internal releases.
- This hosted repository is where your organization will publish internal snapshots.
A Virtual Repository serves as an adaptor to and from different types of repositories. Currently, Nexus supports conversion to and from Maven 1 repositories and Maven 2 repositories. In addition, you can expose any repository format as a NuGet or OBR repository. For example, a Maven 2 repository can contain OSGi Bundles, which can be exposed as a OSGi Bundle repository with the virtual repository Provider set to OBR.
By default it ships with a Central M1 shadow repository that exposes the Central repository in Maven 1 format.
The Repositories window displayed in Figure 6.9, “Repository Configuration Screen for a Proxy Repository” allows you to create, update and delete different repositories with the Add, Delete and Trash button. Use the Refresh button to update the displayed list of repositories and repository groups. The Trash button allows you to empy the trash folder into which deleted components are copied, when any delete operations are performed from the Nexus user interface.
By default, the list of repositories displays the repositories configured and managed by the administrator. The drop down on the right of the Trash button allows you to switch the list of repositories and view the repositories managed by Nexus. There are staging repositories as documented in Chapter 11, Improved Releases with Nexus Staging or procurement repositories as documented in Chapter 10, Nexus Procurement Suite.
The list of repositories visible in Figure 6.9, “Repository Configuration Screen for a Proxy Repository” allows you to access more details for each repository by selecting a specific row which displays some information for each repository in the following columns:
- the name of the repository with repository groups displayed in bold
- the type of the repository with values of proxy, hosted or virtual for repositories or group for a repository group
- Health Check
- the result counts for a repository health check as documented in Chapter 12, Repository Health Check
the format used for the storage in the repository with values
- the deployment policy that applies to this repository. A policy applies only to Maven 1 and Maven 2 formatted repositories and allows usage of a Snapshot or a Release policy.
- Repository Status
- the status of the repository as well as further information about the status. For example, information about SSL certification problems or the status of the remote repository even for a currently disabled proxy repository
- Repository Path
- the direct URL path that exposes the repository via HTTP access and potentially allows access and directory browsing outside of the Nexus interface
Clicking on a colum header allows you to sort the list in ascending or descending order based on the column data.
If you right-click on a row, you can trigger a number of actions on the current repository, depending on the repository type. Actions include:
- Expire Cache
- expire the cache of hosted or a proxy repository or a repository group
- Rebuild Metadata
- rebuid the metadata of a hosted Maven 2 repository
- Block Proxy / Allow Proxy
- toggle between allowing or blocking the remote repository configured in a proxy repository
- Put Out Of Service / Put in Service
- enable or disable the repository service to allow changing the availability of all components in it
- Repair Index / Update Index
- repair or update the index of a hosted or proxy repository or a repository group
Figure 6.9, “Repository Configuration Screen for a Proxy Repository” and Figure 6.10, “Repository Configuration Screen for a Proxy Repository” show the repository configuration screen for a proxy repository in Nexus. From this screen, you can manage the settings for proxying an external repository:
- Repository ID
The repository ID is the identifier that will be used
in the Nexus URL. For example, the proxy repository for the Central
Repository has an ID of
central, this means that Maven and other tools can access the repository directly at
http://localhost:8081/nexus/content/repositories/central. The Repository ID must be unique in a given Nexus installation and is required.
- Repository Name
- The display name for a repository is required.
- Repository Type
- The type of repository (proxy, hosted, or virtual). You can’t change the type of a repository as it is selected when you create a repository.
- Provider and Format
- Provider and Format define in what format Nexus exposes the repository to external tools. Supported formats depend on the installed plugins. Nexus Open Source includes support for Maven 1, Maven 2 and Site repositories. Nexus Professional adds support for NuGet and OBR and additional plugins can add support for P2 and P2 Update Site and other formats.
- Repository Policy
- If a proxy repository has a policy of release, then it will only access released versions from the remote repository. If a proxy repository has a policy of snapshot, it will download snapshots from the remote repository.
- Default Storage Location
- Not editable, shown for reference. This is the default storage location for the local cached contents of the repository.
- Override Storage Location
- You can choose to override the storage location for a specific repository. You would do this if you were concerned about storage and wanted to put the contents of a specific repository (such as central) in a different location.
- Remote Repository Access
This section configures proxy repositories and how Nexus interacts with the remote repository, that is being proxied.
- Remote Storage Location
- The Remote Storage Location needs to be configured with the URL of the remote repository, that needs to be proxied. When selecting the URL to proxy it is beneficial to avoid proxying remote repository groups. Proxying repository groups prevents some performance optimization in terms of accessing and retrieving the content of the remote repository. If you require components from the group that are found in different hosted repositories on the remote repository server it is better to create multiple proxy repositories that proxy the different hosted repositories from the remote server on your Nexus server instead of simply proxying the group.
- Download Remote Indexes
- Download the index of a remote repository can be configured with this setting. If enabled, Nexus will download the index, if it exists, and use that for its searches as well as serve that up to any clients that ask for the index (like m2eclipse). The default for new proxy repositories is enabled, but all of the default repositories included in Nexus have this option disabled. To change this setting for one of the proxy repositories that ship with Nexus, change the option, save the repository, and then re-index the repository. Once this is done, artifact search will return every artifact available on the Maven Central repository.
- Auto Blocking Enabled
- If Auto blocking active is set to true, Nexus will automatically block a proxy repository if the remote repository becomes unavailable. While a proxy repository is blocked, artifacts will still be served to clients from a local cache, but Nexus will not attempt to locate an artifact in a remote repository. Nexus will periodically retest the remote repository and unblock the repository once it becomes available.
- File Content Validation
- If set to true, Nexus will perform a lightweight check on the content of downloaded files. This will prevent invalid content to be stored and proxied by Nexus that otherwise can happen in cases where the remote repository (or some proxy between Nexus and the remote repository) returns a HTML page instead of the requested file.
- Checksum Policy
Sets the checksum policy for a remote repository. This option is set to Warn by default. The possible values of this setting are:
- Ignore - Ignore the checksums entirely
- Warn - Print a warning in the log if a checksum is not correct
- StrictIfExists - Refuse to cache an artifact if the calculated checksum is inconsistent with a checksum in the repository. Only perform this check if the checksum file is present.
- Strict - Refuse to cache an artifact if the calculated checksum is inconsistent or if there is no checksum for an artifact.
- This section allows you to set a Username, Password, NT LAN Host, and NT Lan Manager Domain for a remote repository.
- Access Settings
This section allows for the detailed configuration of access to a repository.
- Deployment Policy
- This setting controls how a Hosted repository allows or disallows artifact deployment. If this policy is set to Read Only, no deployment is allowed. If this policy is set to Disable Redeploy, a client can only deploy a particular artifact once and any attempt to redeploy an artifact will result in an error. If this policy is set to Allow Redeploy, clients can deploy artifacts to this repository and overwrite the same artifact in subsequent deployments. This option is visible for hosted repositories as shown in Figure 6.11, “Repository Configuration Access Settings for a Hosted Repository”.
- Allow File Browsing
- When set to true, users can browse the contents of the repository with a web browser.
- Include in Search
- When set to true, this repository is included when you perform a search in Nexus. If this setting is false, the contents of the repository are excluded from a search.
- Publish URL
- If this property is set to false, the repository will not be published on a URL, and you will not be able to access this repository remotely. You would set this configuration property to false if you want to prevent clients for connecting to this repository directly.
- Expiration Settings
Nexus maintains a local cache of artifacts and metadata, you can configure expiration parameters for a proxy repository. The expiration settings are:
- Not Found Cache TTL
- If Nexus fails to locate an artifact, it will cache this result for a given number of minutes. In other words, if Nexus can’t find an artifact in a remote repository, it will not perform repeated attempts to resolve this artifact until the Not Found Cache TTL time has been exceeded. The default for this setting is 1440 minutes (or 24 hours).
- Artifact Max Age
- Tells Nexus what that maximum age of an artifact is, before it retrieves a new version from the remote repository. The default for this setting is -1 for a repository with a release policy and 1440 for a repository with snapshot policy.
- Metadata Max Age
- Nexus retrieves metadata from the remote repository. It will only retrieve updates to metadata after the Metadata Max Age has been exceeded. The default value for this setting is 1440 minutes (or 24 hours).
- Item Max Age
- Some items in a repository may be neither an artifact identified by the Maven GAV coordinates or metadata for such artifacts. This cache value determines the maximum age for these items before updates are retrieved.
- HTTP Request Settings
- In the HTTP Request Settings you can change the properties of the HTTP request to the remote repository. You can also configure the User Agent of the request, add parameters to a request, and set the timeout and retry behavior. The HTTP request configured is the request made from Nexus to the remote repository being proxied.
Beyond these configurations in the user interface Nexus supports the
usage of cookies for remote repositories authentication. Together
with the feature to enable circular redirects, this enables proxying
repositories like the Oracle Maven repository. The following
configuration can be added to
nexus.properties and allows a functioning
proxy repository to the URL
# Comma separated list of hostnames that needs to accept circular redirections nexus.remoteStorage.enableCircularRedirectsForHosts=maven.oracle.com # Comma separated list of hostnames that benefit from using cookies nexus.remoteStorage.useCookiesForHosts=maven.oracle.com
The Summary panel can be loaded by selecting a hosted, proxy, or
virtual repository and then clicking on the Summary
tab. The Summary tab of a hosted repository, as shown
in Figure 6.12, “Repository Summary Panel for a Hosted Repository”, displays the
distributionManagement settings that can be used to configure
Maven to publish artifacts to the hosted repository.
The Summary panel for a proxy repository, as shown in Figure 6.13, “Repository Summary Panel for a Proxy Repository”, contains all of the repository identifiers and configuration as well as a list of groups in which the repository is contained.
The Summary panel for a virtual repository, as shown in Figure 6.14, “Repository Summary Panel for a Virtual Repository”, displays repository identifiers and configuration as well as the groups in which the repository is contained.
What happens when Nexus is unable to reach a remote repository? If you’ve defined a proxy repository and the remote repository is unavailable, Nexus will now automatically block the remote repository. Once a repository has been auto-blocked, Nexus will then periodically retest the remote repository and unblock the repository once it becomes available. You can control this behavior by changing the Auto Blocking Enabled setting under the Remote Repository Access section of the proxy repository configuration as shown in the following figure to True: