or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

core-model.mdindex.mdplugin-registry.mdsnapshot-management.mdxml-processing.md
tile.json

snapshot-management.mddocs/

Snapshot Management

Comprehensive snapshot artifact handling for SNAPSHOT versions, including build numbers, timestamps, and sub-artifact tracking with support for both legacy and modern snapshot formats.

Capabilities

Snapshot Class

Snapshot data for the last artifact corresponding to the SNAPSHOT base version, containing timestamp and build information.

/**
 * Snapshot data for SNAPSHOT artifacts
 * Contains timestamp, build number, and local copy flag
 */
public class Snapshot implements Serializable, Cloneable {
  // Constructors
  public Snapshot();
  
  // Timestamp management
  public String getTimestamp();
  public void setTimestamp(String timestamp);
  
  // Build tracking
  public int getBuildNumber();
  public void setBuildNumber(int buildNumber);
  
  // Local copy handling
  public boolean isLocalCopy();
  public void setLocalCopy(boolean localCopy);
  
  // Object operations
  public Snapshot clone();
}

Usage Examples:

import org.apache.maven.artifact.repository.metadata.Snapshot;

// Create snapshot for deployment
Snapshot snapshot = new Snapshot();
snapshot.setTimestamp("20231201.143022"); // Format: yyyyMMdd.HHmmss
snapshot.setBuildNumber(1);
snapshot.setLocalCopy(false);

// Update for next deployment
snapshot.setBuildNumber(snapshot.getBuildNumber() + 1);
snapshot.setTimestamp("20231201.145030");

// Check if using local copy
if (snapshot.isLocalCopy()) {
    // Use base version filename instead of timestamped
    System.out.println("Using local copy with base version filename");
}

SnapshotVersion Class

Versioning information for sub-artifacts of snapshot artifacts, tracking different classifier/extension combinations.

/**
 * Versioning information for sub-artifacts of snapshot artifacts
 * Each classifier/extension pair represents a unique sub-artifact
 */
public class SnapshotVersion implements Serializable, Cloneable {
  // Constructors
  public SnapshotVersion();
  
  // Artifact identification
  public String getClassifier();
  public void setClassifier(String classifier);
  public String getExtension();
  public void setExtension(String extension);
  
  // Version tracking
  public String getVersion();
  public void setVersion(String version);
  public String getUpdated();
  public void setUpdated(String updated);
  
  // Object operations
  public SnapshotVersion clone();
  public boolean equals(Object other);
  public int hashCode();
  public String toString();
}

Usage Examples:

import org.apache.maven.artifact.repository.metadata.SnapshotVersion;

// Main JAR snapshot version
SnapshotVersion mainJar = new SnapshotVersion();
mainJar.setClassifier("");
mainJar.setExtension("jar");
mainJar.setVersion("1.2.0-20231201.143022-1");
mainJar.setUpdated("20231201143022");

// Sources JAR snapshot version
SnapshotVersion sourcesJar = new SnapshotVersion();
sourcesJar.setClassifier("sources");
sourcesJar.setExtension("jar");
sourcesJar.setVersion("1.2.0-20231201.143022-1");
sourcesJar.setUpdated("20231201143022");

// Javadoc JAR snapshot version
SnapshotVersion javadocJar = new SnapshotVersion();
javadocJar.setClassifier("javadoc");
javadocJar.setExtension("jar");
javadocJar.setVersion("1.2.0-20231201.143022-1");
javadocJar.setUpdated("20231201143022");

// Check equality (based on classifier, extension, version, updated)
boolean same = mainJar.equals(sourcesJar); // false - different classifiers

Snapshot Version Management

Integration of snapshot and snapshot version information in the versioning system.

// Snapshot management methods in Versioning class
public Snapshot getSnapshot();
public void setSnapshot(Snapshot snapshot);
public List<SnapshotVersion> getSnapshotVersions();
public void setSnapshotVersions(List<SnapshotVersion> snapshotVersions);
public void addSnapshotVersion(SnapshotVersion snapshotVersion);
public void removeSnapshotVersion(SnapshotVersion snapshotVersion);

Usage Examples:

import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.artifact.repository.metadata.Snapshot;
import org.apache.maven.artifact.repository.metadata.SnapshotVersion;

// Set up versioning for snapshot
Versioning versioning = new Versioning();
versioning.setLatest("1.2.0-SNAPSHOT");

// Create snapshot info
Snapshot snapshot = new Snapshot();
snapshot.setTimestamp("20231201.143022");
snapshot.setBuildNumber(1);
versioning.setSnapshot(snapshot);

// Add snapshot versions for different artifacts
SnapshotVersion jarVersion = new SnapshotVersion();
jarVersion.setExtension("jar");
jarVersion.setVersion("1.2.0-20231201.143022-1");
jarVersion.setUpdated("20231201143022");
versioning.addSnapshotVersion(jarVersion);

SnapshotVersion pomVersion = new SnapshotVersion();
pomVersion.setExtension("pom");
pomVersion.setVersion("1.2.0-20231201.143022-1");
pomVersion.setUpdated("20231201143022");
versioning.addSnapshotVersion(pomVersion);

// Access snapshot versions
List<SnapshotVersion> versions = versioning.getSnapshotVersions();
for (SnapshotVersion version : versions) {
    System.out.printf("Extension: %s, Version: %s%n", 
                      version.getExtension(), version.getVersion());
}

Legacy vs Modern Snapshot Formats

The library supports both Maven 2 legacy format and modern snapshot formats with intelligent merging.

Legacy Format (Maven 2):

  • Only contains basic snapshot information (timestamp, build number)
  • No snapshot versions list
  • Used by older Maven versions

Modern Format (Maven 3+):

  • Contains detailed snapshot versions for each sub-artifact
  • Tracks classifier/extension combinations separately
  • Provides more granular control

Merging Behavior:

// Legacy format detection and handling
Metadata legacyMetadata = new Metadata();
Versioning legacyVersioning = new Versioning();
Snapshot legacySnapshot = new Snapshot();
legacySnapshot.setTimestamp("20231201.120000");
legacySnapshot.setBuildNumber(1);
legacyVersioning.setSnapshot(legacySnapshot);
// Note: No snapshot versions list in legacy format

Metadata modernMetadata = new Metadata();
Versioning modernVersioning = new Versioning();
// ... add snapshot versions list

// Merging preserves format compatibility
// Never converts from legacy to modern format
// Never converts from modern to legacy format
boolean changed = legacyMetadata.merge(modernMetadata);
// Result maintains legacy format

Timestamp Formats

The library uses specific timestamp formats for different contexts:

  • Snapshot timestamps: yyyyMMdd.HHmmss (e.g., "20231201.143022")
  • Updated timestamps: yyyyMMddHHmmss (e.g., "20231201143022")
  • All timestamps use UTC timezone

Error Handling

Snapshot management includes robust error handling:

  • Format validation: Timestamp formats are validated during parsing
  • Null safety: Default values prevent null pointer exceptions
  • Clone safety: Deep cloning preserves all snapshot data
  • Equality checking: Proper equals/hashCode implementation for collections