Chapter 06Lesson 03140–180 min

Maven 2 Repositories, Snapshots, Releases, Metadata, Checksums, and Maven Client Configuration: Configuration, Design Choices, and Tradeoffs

Choose Maven repository policies deliberately: release versus snapshot separation, mirror scope, deployment policy, checksum/signature expectations, internal namespace routing, and client-cache boundaries.

mirrorOfDeployment policyNamespace controlCache boundariesTradeoffs

Learning objectives

  • Choose separate or mixed Maven repositories based on lifecycle and policy rather than convenience alone.
  • Select mirrorOf scope that controls egress without unintentionally redirecting localhost/file-based integration repositories.
  • Use deployment policy to protect releases from accidental mutation while allowing snapshot evolution where appropriate.
  • Separate checksum validation, signatures, authenticated publication, namespace ownership, and supply-chain policy into distinct controls.
  • Explain Maven local-cache behavior separately from Nexus proxy-cache behavior.

1. Release/snapshot separation is an operating control

Sonatype supports Maven repositories with Release, Snapshot, or Mixed version policies. A Mixed repository is valid, but separate hosted repositories create clearer retention, permissions, promotion, cleanup, and incident boundaries. A developer can be allowed to publish snapshots while release publication remains a narrower CI privilege. Operations can retain releases longer than snapshots without encoding every lifecycle distinction into one policy.

Choice Benefit Cost / risk Observable state
Separate release + snapshot hosted repos Clear lifecycle, privileges, retention and write policy More repository objects to operate Requests land in distinct repositories/blob mappings; group aggregates both.
Mixed hosted repo Fewer endpoints Release/snapshot governance is less explicit One repository accepts both version classes according to Mixed policy.
Single read group Simple developer configuration Member order and namespace ownership become important Maven reads one URL; Nexus resolves among ordered members.

2. mirrorOf: control egress at the Maven client

Apache Maven's mirror rules map repository IDs to an alternate URL; Maven does not aggregate multiple matching mirrors. * redirects every repository request to the selected mirror. external:* excludes localhost and file repositories, which can be useful when integration tests intentionally use local fixtures.

Pattern Meaning When useful
* Mirror all repository requests Strict Nexus-only dependency egress when the group can satisfy every required repository.
external:* Mirror non-local, non-file repositories Keep local/file integration fixtures direct while routing external egress through Nexus.
*,!special Mirror all except an explicitly named repo Controlled exception; requires governance because it creates a bypass route.

The central question is not “which pattern is shortest?” It is “which network paths does the organization intentionally allow?” A bypass around Nexus can defeat routing rules, caching, namespace controls, audit assumptions, and later Repository Firewall/IQ policies.

3. Deployment policy protects artifact identity

Current Nexus hosted repositories expose three deployment policies: Disable redeploy (the default), Allow redeploy, and Read-only. For releases, Disable redeploy is the safer default because a coordinate such as 1.0.0 should continue to identify the same bytes. If a fix is required, publish 1.0.1 rather than rewriting history.

Snapshots have different semantics. Repeated snapshot publication should create/update the metadata needed to locate unique snapshot values. That mutability belongs in the snapshot lane, not the release lane.

4. Checksums and signatures: choose what failure you are trying to detect

Control Detects / establishes Does not establish
Checksum Unexpected byte change relative to known digest Publisher identity, provenance, vulnerability safety
Cryptographic signature Signature from a key that the verifier trusts Whether dependencies are vulnerability-free
Nexus authentication/authorization Who may perform repository operations Whether build steps themselves were trustworthy
Provenance attestation Evidence about build process/materials when generated and verified correctly Runtime vulnerability status by itself

Do not “fix” checksum or TLS errors by disabling validation. Determine whether the expected artifact changed, the upstream is wrong, local cache is corrupt, or a network/proxy layer modified the response.

Maven can make checksum handling explicit in a repository definition. In a disposable client profile, checksumPolicy=fail tells Maven to fail when checksum validation fails instead of merely warning. This is a client-side repository policy; it is not PGP signature verification and it does not establish provenance.

<repository>
  <id>academy-public</id>
  <url>http://127.0.0.1:8081/repository/academy-ch06-public/</url>
  <releases>
    <enabled>true</enabled>
    <checksumPolicy>fail</checksumPolicy>
  </releases>
  <snapshots>
    <enabled>true</enabled>
    <checksumPolicy>fail</checksumPolicy>
  </snapshots>
</repository>

When a mirror with mirrorOf=* redirects this repository, the mirror controls the actual remote URL while the repository policy still expresses how Maven treats release/snapshot updates and checksums for that repository definition. Keep these client semantics separate from Nexus blob checksums, package signatures, and Nexus authorization.

5. Internal coordinates and dependency-confusion risk

If com.example.academy is your controlled internal namespace, allowing Maven to fall back directly to public repositories can create ambiguity: a public artifact with the same coordinate may satisfy a request depending on routing and version selection. A Nexus group with internal hosted repositories ordered ahead of public proxies helps express ownership, but client/network governance must also prevent unapproved bypass.

Namespace ownership and resolution decision
flowchart TD
Q[Maven requests internal GAV] --> M[Mirror routes to Nexus group]
M --> H{Internal hosted match?}
H -->|yes| I[Serve controlled internal artifact]
H -->|no| P{Public proxy allowed for namespace?}
P -->|blocked by routing policy| F[Fail closed and investigate]
P -->|allowed| U[Query approved public upstream]
U --> C[Cache result in proxy]
C --> Q

Routing rules are taught in Chapter 13, but the principle belongs here: the client mirror, group order, repository routing rule, and network egress policy are different controls. Do not assume one replaces all the others.

6. Maven local cache versus Nexus proxy cache

Maven's local repository belongs to one workstation/CI workspace. Nexus's proxy cache belongs to the shared repository service. If a dependency exists in ~/.m2, Maven may not ask Nexus at all. If it is absent locally but cached in Nexus, Maven contacts Nexus while Nexus may not contact Central. If both caches are cold, the request can reach the upstream.

State Maven contacts Nexus? Nexus contacts upstream?
Local cache hit Usually no No
Local miss + Nexus proxy hit Yes Usually no
Local miss + Nexus proxy miss Yes Yes, if routing/network/upstream permit
Snapshot with update due Yes depending Maven update policy Nexus may revalidate metadata according to proxy cache policy

7. Worked decision: 40 developers, protected releases

Requirement: developers consume internal releases, snapshots and Central through one URL; only CI publishes releases; developers may publish snapshots; integration tests occasionally use file repositories; internal namespaces must not resolve from the public Internet.

Decision Selection Reason
Read endpoint One Maven group Minimizes client config and keeps member order under Nexus control.
Hosted topology Separate releases/snapshots Different write identities and lifecycle policies.
Release deployment policy Disable redeploy Preserves coordinate-to-byte identity.
Mirror scope external:* plus explicit governance of exceptions Keeps deliberate local/file fixtures while routing external egress through Nexus.
Namespace protection Hosted members first + routing rule + network/client policy Multiple layers prevent accidental public fallback.
Credentials Developer snapshot identity; separate CI release identity Least privilege and auditable publication boundary.

8. Design exercise: write an ADR before touching Nexus

Create a one-page architecture decision record with: read endpoint, release target, snapshot target, mirror pattern, allowed exceptions, deployment policies, internal namespace prefixes, publisher identities, retention intent, and how you will test a fresh client. Then compare the ADR to the repository configuration from Lesson 2. Any mismatch is either a configuration bug or an undocumented design change.

Knowledge check

Why might external:* be safer than * for some test environments?

Why should a stable release repository usually disable redeploy?

Can group member order alone prevent dependency confusion if clients can reach Central directly?

Which cache should you clear first when proving Nexus behavior: the shared proxy cache or a disposable Maven local cache?

Why is an .asc signature not a vulnerability scan?

9. Summary

Maven repository design is policy expressed through version lanes, mirror scope, namespace routing, deployment immutability, credentials, and cache boundaries. The next lesson deliberately breaks those boundaries and diagnoses the evidence in the correct order.

Next lesson

Diagnose failures without destroying evidence

Separate client, repository, authorization, metadata, cache, upstream and storage causes.

Official references and version notes

Version-sensitive statements were rechecked against Sonatype and Apache Maven primary documentation on 2026-08-26. The mandatory lab pins Nexus Repository Community Edition 3.95.2 and Apache Maven 3.9.16. Nexus 3.95.2 was released 2026-08-21; Maven 3.9.16 is the current recommended Maven 3 release. Nexus 3.87+ requires Java 21 when using an external JVM and official Nexus packages include a bundled Java 21 runtime. Re-check live support/download pages before executing these labs.

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0 Send only Ethereum/ERC-20 compatible assets to this address.