Skip to main content

Common Misconfigurations

  1. Using SNAPSHOT versions in production
  2. Not controlling snapshot update frequency
  3. Allowing snapshots from untrusted repositories
  4. Missing snapshot versioning policies
  5. Not locking snapshot versions before release

Vulnerable Example

Secure Solution

Key Commands for Managing Snapshots

These commands help you work with the secure snapshot lifecycle.

1. Activating the Development Profile

To use the secure snapshot repository, you must activate the development profile shown in the example.
This is the only way to allow Maven to find and download snapshot dependencies from your secure repository.

2. Forcing a Snapshot Update

Even with an updatePolicy of daily, you may need to force Maven to check for a newer snapshot. The -U flag does this.

3. Enforcing No Snapshots

To manually run the enforcer plugin (as shown in the “Secure Solution”) and fail the build if any snapshot dependencies are found:
This is often bound to the verify or package phase, but you can run it manually to check.

4. Converting Snapshots to Releases (The “Lock”)

When you are ready to release, you must convert all 1.0-SNAPSHOT versions to a stable 1.0.0 version. The versions-maven-plugin is great for this.

5. Starting the Next Development Cycle

After the release, you need to change the version from 1.0.0 to 1.1-SNAPSHOT (or similar).
The maven-release-plugin (mvn release:prepare) automates steps 4 and 5, but these are the underlying commands.

Best Practices

  • Never use SNAPSHOT dependencies in production.
  • Implement strict snapshot policies.
  • Use Maven Enforcer Plugin to prevent snapshot usage.
  • Lock versions before releases.
  • Use separate repositories for snapshots and releases.