Maven and Nexus Tutorial: Part 3

Published: Feb 21, 2019 by Isaac Johnson

Nexus is used as a medium between components.

Repositories:

  1. Plugin: where to fetch build plugins
  2. Repository: similar to above, where to find plugins, parent poms, etc
  3. Distribution repository: where to transmit built things.  If you define a distributionManagement block with repository and snapshotRepository, maven will pick the right target based on project.version (if it ends in “-SNAPSHOT”)

Group repositories merge things. An order is defined in nexus allowing overrides.  

Proxies will serve a local cache if available, otherwise reach out to a remote repository.

/content/images/2019/02/image-14.png

One can proxy any remote repository.  You can use scheduled tasks, smart proxies and release steps to force proxy syncs, however you can also set up a remote proxy with syncing disabled (to fix versions).

A Nexus Proxy server is still a nexus server and can host locally built artifacts (e.g. nextrel-dev)

/content/images/2019/02/image-13.png

Distribution

The distributionManagement block is only set up with snapshots.  However one will need to provide a settings.xml file with username and password defined.

One can do this a few ways.

  1. Pass in -Dusername=xxx -Dpassword=xxx and reference them in a file
  2. Set environment variables and use ${ENV.NEXUS_USER} and ${ENV.NEXUS_PASS}
  3. Dynamically generate one (eg. gensettings.ps1)

Have something to add? Feedback? Try our new forums

Isaac Johnson

Isaac Johnson

Cloud Solutions Architect

Isaac is a CSA and DevOps engineer who focuses on cloud migrations and devops processes. He also is a dad to three wonderful daughters (hence the references to Princess King sprinkled throughout the blog).

Theme built by C.S. Rhymes