Nexus Repository with Mule 4

Author: Mohammad Mazhar Ansari

In this blog, we will try to learn how to use our own Nexus Repository with Mule 4.

What is Nexus OSS?

  • Nexus Repository OSS is an open source repository that supports many artifact formats, including Docker, Java™, and npm.
  • With the Nexus tool integration, pipelines in your toolchain can publish and retrieve versioned apps and their dependencies by using central repositories that are accessible from other environments.

How to download Nexus OSS?

  • You can download Nexus OSS by registering here.
  • However, I prefer the docker image which I downloaded from here.

Install and Run Nexus OSS

If you have downloaded the Windows version of Nexus OSS as a zip file, then

  • Unzip Nexus OSS zip file in folder called <Nexus-Home>
  • Go to <Nexus-Home>
  • Open command prompt
  • Run command “nexus.exe /run

If you have docker image on a unix system like I did, then

  • docker pull sonatype/nexus3
  • mkdir /opt/docker/nexus-data && chown -R 200 /opt/docker/nexus-data
  • docker run -d -p 8081:8081 –name nexus -v /opt/docker/nexus-data:/nexus-data sonatype/nexus3
  • /opt/doker/nexus-data is custom directory i created for Mount a host directory as the volume
  • Open http://<your-h0st>:8081
  • Click on Sign in
  • Default username is admin and password is admin123

Configuring Nexus as a Maven repo:

To use Nexus as maven repo, we need to create 4 repositories.

  • create a private (hosted) repository for our snapshots (maven-snapshots)
  • create a private (hosted) repository for our releases (maven-releases)
  • create a proxy repository pointing to Maven Central (maven-central)
  • create a group repository to provide all of these repos under a single URL (maven-public)

I suggest you to create a new blob store for each new repo you want to create. In that way, the data for every repo will be in a different folder in /nexus-data (inside the Docker container). But this step is not mandatory for it to work.

The Docker image that I had created already has all 4 repositories.

Configuring Nexus repos in Maven:

Update <User-Home>/.m2/settings.xml file

  • Add below lines under <servers>
  • Add below lines under <mirrors>

Configure your Mule 4 project: 

If you want only to download dependencies from Nexus, add below lines under project/repositories in project’s pom.xml.


And if you also want to publish your project, add below lines under project/distributionManagement in project’s pom.xml.


Nexus, Maven and Mule 4 in Action:

Run below command from command project within Mule 4 project directory.

  • mvn deploy
  • You can see the jar in maven-snapshots repository.

Note: As pom.xml version contains SNAPSHOT version, that is the reason why it got uploaded in maven-snapshots repository. Else, it will be uploaded in maven-releases repository.

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.