CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-biz-a-qute-bnd--biz-a-qute-bndlib

bndlib: A Swiss Army Knife for OSGi providing comprehensive bundle manipulation and analysis capabilities

Pending
Overview
Eval results
Files

version-management.mddocs/

Version Management

OSGi-compliant version handling and semantic versioning for dependency resolution and compatibility analysis.

Capabilities

Version

OSGi version implementation with semantic versioning support for precise dependency management.

/**
 * OSGi version implementation with semantic versioning support
 */
public class Version implements Comparable<Version> {
    /** Create version with all components */
    public Version(int major, int minor, int micro, String qualifier);
    
    /** Create version with major, minor, micro */
    public Version(int major, int minor, int micro);
    
    /** Create version with major, minor */
    public Version(int major, int minor);
    
    /** Create version with just major */
    public Version(int major);
    
    /** Parse version from string */
    public static Version parseVersion(String version);
    
    /** Get major version number */
    public int getMajor();
    
    /** Get minor version number */
    public int getMinor();
    
    /** Get micro version number */
    public int getMicro();
    
    /** Get qualifier string */
    public String getQualifier();
    
    /** Compare with another version */
    public int compareTo(Version other);
    
    /** Check equality with another version */
    public boolean equals(Object obj);
    
    /** Get hash code */
    public int hashCode();
    
    /** Convert to string representation */
    public String toString();
    
    /** Check if this is higher than another version */
    public boolean isHigher(Version other);
    
    /** Check if this is lower than another version */
    public boolean isLower(Version other);
    
    /** Get base version (without qualifier) */
    public Version getWithoutQualifier();
}

Usage Examples:

import aQute.bnd.version.Version;

// Create versions
Version v1 = new Version(1, 2, 3, "SNAPSHOT");
Version v2 = Version.parseVersion("2.0.0");
Version v3 = new Version(1, 2, 4);

// Compare versions
System.out.println(v1.compareTo(v2)); // negative (v1 < v2)
System.out.println(v1.compareTo(v3)); // negative (v1 < v3)
System.out.println(v2.isHigher(v1));  // true

// Version components
System.out.println("Major: " + v1.getMajor());     // 1
System.out.println("Minor: " + v1.getMinor());     // 2  
System.out.println("Micro: " + v1.getMicro());     // 3
System.out.println("Qualifier: " + v1.getQualifier()); // SNAPSHOT

// String representation
System.out.println(v1.toString()); // "1.2.3.SNAPSHOT"
System.out.println(v2.toString()); // "2.0.0"

// Version without qualifier
Version base = v1.getWithoutQualifier(); // "1.2.3"

VersionRange

Represents a version range for dependency resolution with inclusion/exclusion rules.

/**
 * Represents a version range for dependency resolution
 */
public class VersionRange {
    /** Parse version range from string */
    public static VersionRange parseVersionRange(String range);
    
    /** Create range with floor and ceiling */
    public VersionRange(String floor, boolean floorInclusive, String ceiling, boolean ceilingInclusive);
    
    /** Check if version is included in range */
    public boolean includes(Version version);
    
    /** Check if range includes another range */
    public boolean includes(VersionRange other);
    
    /** Get intersection with another range */
    public VersionRange intersect(VersionRange other);
    
    /** Check if range intersects with another */
    public boolean intersects(VersionRange other);
    
    /** Get floor version */
    public Version getFloor();
    
    /** Check if floor is inclusive */
    public boolean isFloorInclusive();
    
    /** Get ceiling version */
    public Version getCeiling();
    
    /** Check if ceiling is inclusive */
    public boolean isCeilingInclusive();
    
    /** Check if this is an exact version (not a range) */
    public boolean isExact();
    
    /** Convert to string representation */
    public String toString();
    
    /** Convert to OSGi version range string */
    public String toOSGiString();
}

Usage Examples:

import aQute.bnd.version.VersionRange;
import aQute.bnd.version.Version;

// Parse version ranges
VersionRange range1 = VersionRange.parseVersionRange("[1.0,2.0)");  // 1.0 <= v < 2.0
VersionRange range2 = VersionRange.parseVersionRange("(1.5,)");     // v > 1.5
VersionRange range3 = VersionRange.parseVersionRange("[1.2.3]");    // exactly 1.2.3

// Check version inclusion
Version v = new Version(1, 5, 0);
System.out.println(range1.includes(v)); // true
System.out.println(range2.includes(v)); // false (1.5.0 not > 1.5)
System.out.println(range3.includes(v)); // false

// Range operations  
VersionRange intersection = range1.intersect(range2);
System.out.println(intersection); // "(1.5,2.0)"

// Range properties
System.out.println("Floor: " + range1.getFloor());           // 1.0.0
System.out.println("Floor inclusive: " + range1.isFloorInclusive()); // true
System.out.println("Ceiling: " + range1.getCeiling());       // 2.0.0
System.out.println("Ceiling inclusive: " + range1.isCeilingInclusive()); // false

Version Utilities

Utility classes for version manipulation and analysis.

/**
 * Utilities for version manipulation and analysis
 */
public class VersionUtils {
    /** Check if version satisfies range */
    public static boolean satisfies(Version version, String range);
    
    /** Get highest version from collection */
    public static Version highest(Collection<Version> versions);
    
    /** Get lowest version from collection */
    public static Version lowest(Collection<Version> versions);
    
    /** Filter versions by range */
    public static List<Version> filter(Collection<Version> versions, VersionRange range);
    
    /** Increment version component */
    public static Version increment(Version version, VersionComponent component);
    
    /** Calculate semantic version change */
    public static VersionChange calculateChange(Version from, Version to);
    
    /** Validate version string */
    public static boolean isValid(String version);
    
    /** Normalize version string */
    public static String normalize(String version);
}

/**
 * Version components for increment operations
 */
public enum VersionComponent {
    MAJOR, MINOR, MICRO, QUALIFIER
}

/**
 * Types of version changes
 */
public enum VersionChange {
    MAJOR,    // Breaking changes
    MINOR,    // New features, backward compatible
    MICRO,    // Bug fixes
    QUALIFIER // Qualifier changes only
}

Maven Version Support

Support for Maven-style version handling and conversion.

/**
 * Maven version representation and conversion
 */
public class MavenVersion implements Comparable<MavenVersion> {
    /** Parse Maven version string */
    public static MavenVersion parseMavenVersion(String version);
    
    /** Convert to OSGi version */
    public Version toOSGiVersion();
    
    /** Get version string */
    public String getVersion();
    
    /** Check if snapshot version */
    public boolean isSnapshot();
    
    /** Get base version (without SNAPSHOT) */
    public MavenVersion getBaseVersion();
    
    /** Compare with another Maven version */
    public int compareTo(MavenVersion other);
}

/**
 * Utilities for Maven version handling
 */
public class MavenVersionUtils {
    /** Convert Maven version to OSGi */
    public static Version toOSGi(String mavenVersion);
    
    /** Convert OSGi version to Maven */
    public static String toMaven(Version osgiVersion);
    
    /** Check if Maven version is valid */
    public static boolean isValidMavenVersion(String version);
    
    /** Clean up Maven version for OSGi compatibility */
    public static String cleanupVersion(String version);
}

Complete Version Management Example:

import aQute.bnd.version.*;

// Complete version management workflow
public class VersionManagementExample {
    
    public void demonstrateVersionManagement() {
        // Create and parse versions
        Version current = Version.parseVersion("1.2.3");
        Version newer = new Version(1, 3, 0);
        Version snapshot = Version.parseVersion("1.2.4.SNAPSHOT");
        
        System.out.println("Current: " + current);
        System.out.println("Newer: " + newer);
        System.out.println("Snapshot: " + snapshot);
        
        // Version comparison
        if (newer.isHigher(current)) {
            System.out.println("Update available: " + newer);
        }
        
        // Version ranges for dependencies
        VersionRange apiRange = VersionRange.parseVersionRange("[1.0,2.0)");
        VersionRange implRange = VersionRange.parseVersionRange("[1.2,1.3)");
        
        // Check compatibility
        System.out.println("Current compatible with API: " + apiRange.includes(current));
        System.out.println("Current compatible with impl: " + implRange.includes(current));
        
        // Find compatible versions
        List<Version> availableVersions = Arrays.asList(
            Version.parseVersion("0.9.0"),
            Version.parseVersion("1.1.0"), 
            Version.parseVersion("1.2.0"),
            Version.parseVersion("1.2.5"),
            Version.parseVersion("1.3.0"),
            Version.parseVersion("2.0.0")
        );
        
        List<Version> compatible = VersionUtils.filter(availableVersions, apiRange);
        System.out.println("Compatible versions: " + compatible);
        
        Version highest = VersionUtils.highest(compatible);
        System.out.println("Highest compatible: " + highest);
        
        // Maven version conversion
        MavenVersion mavenVer = MavenVersion.parseMavenVersion("1.2.3-SNAPSHOT");
        Version osgiVer = mavenVer.toOSGiVersion();
        System.out.println("Maven: " + mavenVer + " -> OSGi: " + osgiVer);
        
        // Increment versions for releases
        Version nextMicro = VersionUtils.increment(current, VersionComponent.MICRO);
        Version nextMinor = VersionUtils.increment(current, VersionComponent.MINOR);
        Version nextMajor = VersionUtils.increment(current, VersionComponent.MAJOR);
        
        System.out.println("Next micro: " + nextMicro);    // 1.2.4
        System.out.println("Next minor: " + nextMinor);    // 1.3.0
        System.out.println("Next major: " + nextMajor);    // 2.0.0
        
        // Calculate version change type
        VersionChange change = VersionUtils.calculateChange(current, newer);
        System.out.println("Change type: " + change);      // MINOR
    }
}

Install with Tessl CLI

npx tessl i tessl/maven-biz-a-qute-bnd--biz-a-qute-bndlib

docs

api-comparison-diffing.md

core-osgi-processing.md

header-processing.md

index.md

jar-resource-management.md

plugin-architecture.md

repository-system.md

version-management.md

workspace-project-management.md

tile.json