Class VersionSupport

java.lang.Object
network.ike.workspace.VersionSupport

public final class VersionSupport extends Object
Version manipulation for IKE workspace conventions.

Handles SNAPSHOT suffixes, branch-qualified versions, checkpoint versions, and release version derivation. Extracted from ReleaseSupport in ike-maven-plugin so these operations are testable without Maven dependencies.

  • Method Details

    • stripSnapshot

      public static String stripSnapshot(String version)
      Strip -SNAPSHOT from a version string.
      Parameters:
      version - e.g. "1.1.0-SNAPSHOT" or "1.1.0-my-feature-SNAPSHOT"
      Returns:
      e.g. "1.1.0" or "1.1.0-my-feature"
    • deriveReleaseVersion

      public static String deriveReleaseVersion(String snapshotVersion)
      Derive the release version from a SNAPSHOT version. Equivalent to stripSnapshot(String).
      Parameters:
      snapshotVersion - version to strip
      Returns:
      release version without -SNAPSHOT suffix
    • deriveNextSnapshot

      public static String deriveNextSnapshot(String releaseVersion)
      Derive the next SNAPSHOT version by incrementing the last numeric segment. "2" becomes "3-SNAPSHOT"; "1.1.0" becomes "1.1.1-SNAPSHOT".
      Parameters:
      releaseVersion - a version without -SNAPSHOT
      Returns:
      the next SNAPSHOT version
    • safeBranchName

      public static String safeBranchName(String branch)
      Transform a branch name into a safe directory/version qualifier. Replaces / with -.
      Parameters:
      branch - e.g. "feature/shield-terminology"
      Returns:
      e.g. "feature-shield-terminology"
    • branchQualifiedVersion

      public static String branchQualifiedVersion(String baseVersion, String branch)
      Derive a branch-qualified SNAPSHOT version.

      Given base version "1.2.0-SNAPSHOT" and branch "feature/my-work", returns "1.2.0-my-work-SNAPSHOT".

      If the branch is "main", returns the base version unchanged.

      Parameters:
      baseVersion - the unqualified version (with or without -SNAPSHOT)
      branch - the git branch name
      Returns:
      the branch-qualified SNAPSHOT version
    • extractNumericBase

      public static String extractNumericBase(String version)
      Extract the numeric base version, stripping any branch qualifier. "1.2.0-my-feature" becomes "1.2.0"; "1.2.0" is unchanged.

      The numeric base is the leading run of dot-separated digit groups, ending at the first -; everything after it is qualifier. That holds for a feature slug that starts with a digit too — "7-8bp-jdk27" becomes "7" — so re-qualifying an already-qualified version is idempotent (ike-issues#1136).

      Parameters:
      version - version string possibly containing a branch qualifier
      Returns:
      numeric portion only
    • isSnapshot

      public static boolean isSnapshot(String version)
      Check whether a version string is a SNAPSHOT.
      Parameters:
      version - version to check
      Returns:
      true if version ends with -SNAPSHOT
    • isBranchQualified

      public static boolean isBranchQualified(String version)
      Check whether a version string is branch-qualified (has a non-numeric qualifier before -SNAPSHOT).
      Parameters:
      version - version to check
      Returns:
      true if version contains a branch qualifier