Maven and Nexus Tutorial: Part 2

Published: Feb 19, 2019 by Isaac Johnson

Pom Relationships

  1. All POMs can have a parent POM.  They can share a parent. The parent POMs store common settings (e.g. nexus creds, clover license, fixed versions of plugins)
  2. POMs can have modules (sub-pom’s). These can have dependencies. Maven will determine order dynamically based on dependencies
  3. A POM can have 1 and only one top-level artifact. By default, this artifact is what is deployed to Nexus/Artifactory
The inter-POM relationships
  1. The top section of a POM (groupid, artifact, packaging) are properties.  These define the thing in question and are immutable.
  2. The plugins are pulled in at build time and define extra functionality. (e.g. maven-release-plugin can modify the versions, assembly-plugin is a handy way to make tgz/zip/jar files). Often static code scanning tools are brought in this way (e.g. Atlassian Clover)
  3. The build block defines the build steps by target. Similar to make files, targets can be dependent.  Targets, however, are tied to phases so there is a level of abstraction
  4. Environment settings are pretty much the same as properties with the exception that they can be overridden on the command line (e.g. -Dsetting=value -Dothersetting=value)
Parent POM

Artifact Concepts

All artifact stores think about things as either Snapshots or Releases

  1. All artifact stores think about things as either Snapshots or Releases
  2. Snapshots: 1. a candidate of a release (e.g. 1.0-SNAPSHOT aspires to be 1.0). 2. You can upload many (albeit modern repos will append timestamps) 3. Are often scrubbed periodically (e.g. we keep just 2 weeks and/or latest 2 of any snapshot version) 4. Should only be depended on in active development
  3. Releases: 1. One and only one per release 2. Redeploys are not allowed (and painful if required - have to manually scrub, clean up SHAs - avoid this) 3. Are ensured to be stored forever 4. Often the credentials to deploy releases are protected and available only in CI system
  4. Group: 1. a group merges multiple repositories for maven pom consumption. 2. Groups by their nature are not writable
Release vs Snapshot
tutorial maven

Have something to add? Feedback? You can use the feedback form

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