Search...
Toggle theme

Nexus (Maven)

Configure Sonatype Nexus Repository for NES Maven artifacts

Teams using Sonatype Nexus can manage access to NES artifacts through 3 easy steps:

  1. Create a Proxy Repository (NES Remote Repository) for our private Maven registry.
  2. Configure the Proxy Repository with a Routing Rule
  3. Configure a Group Repository to access both NES and OSS packages.

Step 1: Create a Routing Rule

  1. Navigate to Server Administration and Config > Routing Rules
  2. Select Create Routing Rule

"Step 2"

  1. Provide the following configuration values on the Create Routing Rule page. For configuration values not defined below, use the default value that Nexus provides.
Namenes-maven-routing
DescriptionRoute NES requests to HeroDevs registry
ModeAllow
Matchers^/com/herodevs/nes/.*
  1. Create the Routing Rule

Step 2: Create a NES Proxy Repository & Group Repository for your team

First, create a NES Proxy Repository which will handle only the NES artifacts requested.

  1. Navigate to Server Administration and Config > Repositories

"Step 2a"

  1. Select Create Repository, then select Maven (proxy) as the recipe.

"Step 2b"

  1. Provide the following configuration values on the Create Repository page. For configuration values not defined below, use the default value that Nexus provides.
Namenes-maven
Remote Storagehttps://registry.nes.herodevs.com/maven
Blob Storeprovide the appropriate store for your environment
Routing Rulenes-maven-routing (from Step 1)
Authenticationchecked
Authentication TypeUsername
Usernamenexus
Password<NES_ACCESS_TOKEN>
  1. Create the repository.

Next, create a Group Repository for your team so that they can access both NES and public artifacts from a single remote repository.

  1. Navigate to Server Administration and Config > Repositories

"Step 2c"

  1. Select Create Repository, but this time select Maven (group) as the recipe.

"Step 2d"

  1. Provide the following configuration values on the Create Repository page. For configuration values not defined below, use the default value that Nexus provides.
Namemaven-default
Blob Storeprovide the appropriate store for your environment
Membersmaven-central, nes-maven, etc.
  1. Create the repository.

Configuring your Maven/Gradle client

Review the Nexus Maven or Gradle documentation to setup your project or client accordingly.

  1. Configuring Apache Maven
  2. Configuring Gradle

Examples

Maven (settings.xml)
Gradle (build.gradle)
<settings>
  <servers>
    <!-- other servers -->
    <server>
      <id>nexus</id>
      <username>${env.NEXUS_USER}</username>
      <password>${env.NEXUS_PASSWORD}</password>
    </server>
  </servers>
  <profiles>
    <!-- other profiles -->
    <profile>
      <id>nexus</id>
      <repositories>
        <repository>
          <id>nexus</id>
          <name>maven-default</name>
          <url>https://company-nexus.com/repository/maven-default/</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>nexus</id>
          <name>maven-default</name>
          <url>https://company-nexus.com/repository/maven-default/</url>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!-- other active profiles -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>