Understanding Nexus: Introduction To Repositories

Younusraza
4 min readNov 15, 2023

--

This is in continuation of our Nexus Basics Series. In the last part, we learned about what Nexus is and why it is important. We completed that section by installing Nexus on Linux and I also showed how we can spin up Nexus container.

If you missed it you can read the previous part here:

Understanding Nexus: Developer Guide

In this part, we will look into the Types of repositories in Nexus.

Types Of Repositories In Nexus:

When of the key features of Nexus is the ability to organize repositories based on their roles. Here are different types of Nexus repositories and their practical use cases.

If we look into UI Browser we can see some repositories already built for our use. Here we can see different types of repositories like maven-central, maven-public, maven-releases, and others. Let’s understand their use cases.

Note: You might not be login , So in order to login Nexus has created a user for us . Below are the credentials:

username: admin

password: Your admin user password is located in
/nexus-data/admin.password on the server

Now There are 3 main types of Repositories:

  1. Group
  2. Host
  3. Proxy

In the image provided, you’ll notice various folders such as “central,” “snapshot,” and more. They simplify the process of classifying artifacts, making it easier for developers to know where each type of artifact belongs.

So, what’s the general rule? It’s a straightforward one. Each folder corresponds to a specific type of repository, helping you decide where to place your artifacts. Let’s take a quick tour to understand the logic behind these folders.

1. Public Repository (Type: Group)

Use Case: Sharing Open-Source Components

As the name suggests here we keep all our folders (artifacts) that we need to make available to the public. It’s the go-to place for sharing libraries, frameworks, and other code snippets with the wider developer community.

2. Releases Repository (Type: Hosted)

Use Case: Stable Releases

Honestly, our code isn’t always ready for prime-time release. Nexus allows you to separate those releases which are ready to release and which are not. In these types of repositories, you push those builds that are well-tested and designated for further process.

3. Snapshot Repository (Type: Hosted)

Use Case: Continuous Integration and Testing

Snapshots are like works in progress. The snapshot repository in Nexus is where you store evolving versions of your project during development. This is particularly useful for continuous integration, enabling developers to access the latest, potentially unstable, builds for testing purposes.

4. Hosted Repository (Type: Hosted)

Use Case: Your Private Stash

Think of the hosted repository as your personal storage unit within Nexus. It’s where you keep your unique, in-house artifacts that aren’t meant for public consumption. Most of the time you are using Hosted Repositories either it is Snapshot or Release Type.

5. Grouped Repository (Type: Group)

Use Case: Simplifying Access

A grouped repository is like a virtual repository that simplifies access to multiple repositories. You can combine various repositories, be it public, releases, or snapshots, into a single group. This way, developers only need to configure their build tools once to access all the repositories they need.

6. Proxy Repository (Type: proxy)

The most important type of repository in Nexus is the proxy repository. To understand that, let’s consider a example where you’re developing a Node.js application. As a developer, when you run the npm i command to install dependencies, the system may be configured to prevent direct communication with external, third-party repositories. In such cases, your system would communicate with Nexus, asking it to fetch the required packages.

Here’s how it works:

  1. Local Check: Nexus first checks its local memory to see if it already has the requested dependencies stored.
  2. Proxy to Third-Party Manager: If the dependencies are not found locally, Nexus acts as a proxy to the third-party manager (like npm in this case). It fetches the required dependencies from the external repository.
  3. Caching for Optimization: Importantly, Nexus caches these dependencies locally. This means that if the same request is made again, Nexus can provide the dependencies directly from its cache without having to go back to the external repository. This caching mechanism significantly improves performance by reducing the need for repeated external fetches.

Conclusion

In this part of our Nexus blog series, we’ve explored the types of Nexus Repositries.We have learnt about when to use which type of repository. There are still a lot but do not worry we will cover a lot of basic stuff here.Stay tuned.

If you found this content helpful, please show your support by giving it a clap, following me on LinkedIn and YouTube, and considering making a small contribution to Buy Me a Coffee☕️. Your support is greatly appreciated!

--

--