8.3. Setting up a Procured Repository

This section will walk through the process of creating and configuring a hosted repository named "Procured Central" which will be procured from the "Maven Central" proxy repository. Setting up a procured repository consists of the following steps:

  • Enabling Remote Index Downloads for a Proxy Repository

  • Creating a Hosted Repository to be Procured

  • Configuring Procurement for the Hosted Repository

  • Configuring Procurement Rules

Before configuring a procured repository, you need to make sure that you have enabled Remote Index downloading for the proxied repository that will serve as the source for your procured repository.

Note

If you are attempting to procure artifacts from a remote repository which does not have a repository index, you can still use the procurement suite. Without a remote repository index, you will need to configure procurement rules manually without the benefit of the already populated repository tree shown in Section 8.4., “Configuring a Procurement Rule”.

8.3.1. Enable Remote Index Downloads

When you configure procurement rules for a hosted repository, the administrative interface displays the repository as a tree of groups and artifacts populated from the Remote Repository's Nexus Index. Nexus ships with a set of proxy repositories, but remote index downloading is disabled by default. To use procurement, you will need to tell Nexus to download the remote indexes for a proxy repository. Click on "Repositories" under Views/Repositories in the Nexus menu, then click on the Maven Central repository in the list of repositories. Click on the Configuration tab, locate Download Remote Indexes, and switch this option to "True" as shown in Figure 8.4, “Enabling Remote Index Downloads for a Proxy Repository”.

Enabling Remote Index Downloads for a Proxy Repository

Figure 8.4. Enabling Remote Index Downloads for a Proxy Repository


Click on the Save button in the dialog shown in Figure 8.4, “Enabling Remote Index Downloads for a Proxy Repository”. Right-click on the Index in the Repositories list and select "Re-Index". Nexus will then download the remote repository and recreate the index for any Repository Groups that contain this proxied repository. Nexus may take a few minutes to download the remote index for a large repository. Depending on your connection to the Internet, this process can take anywhere from under a minute to a few minutes. The size of the remote index for Maven Central is on the order of 30 MB. To check on the status of the remote index download, click on System Feeds under Views in the Nexus menu. Click on the last feed to see a list of "System Changes in Nexus". If you see a log entry like the one highlighted in Figure 8.5, “Verification that the Remote Index has been Downloaded”, Nexus has successfully downloaded the Remote Index from Maven Central.

Verification that the Remote Index has been Downloaded

Figure 8.5. Verification that the Remote Index has been Downloaded


8.3.2. Create a Hosted Repository

When you configure procurement you are establishing a relationship between a Proxy repository and a Hosted repository. To create a Hosted repository, select Repositories from the Administration section of the Nexus menu, and click on the Add button selecting Hosted as shown in Figure 8.6, “Adding a Hosted Repository”.

Adding a Hosted Repository

Figure 8.6. Adding a Hosted Repository


Selecting Hosted will then load the Repository Config form shown in Figure 8.7, “Adding the "Secured" Hosted Repository”. Create a repository with a Repository ID of "secured" and a name of "Secured". Make the release policy "Release". Click the Save button to create the new Hosted Repository.

Adding the "Secured" Hosted Repository

Figure 8.7. Adding the "Secured" Hosted Repository


8.3.3. Configuring Procurement for Hosted Repository

At this point, the list of Repositories will have a new Hosted repository named "Secured". The next step is to start procurement for the new Secured repository. When you do this, you are establishing a relationship between the new Hosted repository and a Proxy repository. In this case, we're configuring procurement for the Secured repository and we're telling the Procurement Suite to procure artifacts from the Maven Central proxy repository. To configure this relationship and to start procurement, click on Artifact Procurement under the Enterprise menu. In the Procurement panel, click on Add Procurement Repository as shown in Figure 8.8, “Adding a Procured Repository”.

Adding a Procured Repository

Figure 8.8. Adding a Procured Repository


You will then be presented with the Start Procurement dialog as shown in Figure 8.9, “Configuring Procurement for a Hosted Repository”. Select the "Maven Central" proxy repository from the list of available Source repositories.

Configuring Procurement for a Hosted Repository

Figure 8.9. Configuring Procurement for a Hosted Repository


Procurement is now configured and started, if you are using an instance of Nexus installed on localhost port 8081, you can configure your clients to reference the new Secured repository at http://localhost:8081/nexus/content/repositories/secured. By default, all artifacts are denied and without further customization of the procurement rules no artifacts will be available in the new Secured repository.

One interesting thing to note about the "Secured" repository is that the Repository Type changed, once procurement was started. When procurement is activate for a Hosted repository, the repository will show up in the Nexus interface as a Proxy repository. Click refresh in the Repositories list, and look at the Secured repository in the list of repositories, you will see that the repository type column contains "proxy" as shown in Figure 8.10, “Hosted Repository is a Proxy Repository while Procurement is Active”. When procurement is started for a hosted repository it is effectively a proxy repository, and when it is stopped it will revert back to being a normal hosted repository.

Hosted Repository is a Proxy Repository while Procurement is Active

Figure 8.10. Hosted Repository is a Proxy Repository while Procurement is Active