Class ModelVersionUtils

java.lang.Object
org.apache.maven.cling.invoker.mvnup.goals.ModelVersionUtils

public final class ModelVersionUtils extends Object
Utility class for handling Maven model version operations during upgrades.
  • Method Details

    • detectModelVersion

      public static String detectModelVersion(org.jdom2.Document pomDocument)
      Detects the model version from a POM document. Uses both the modelVersion element and namespace URI for detection.
      Parameters:
      pomDocument - the POM document
      Returns:
      the detected model version
    • isValidModelVersion

      public static boolean isValidModelVersion(String modelVersion)
      Checks if a model version is valid for upgrade operations. Currently only supports 4.0.0 and 4.1.0.
      Parameters:
      modelVersion - the model version to validate
      Returns:
      true if the model version is valid
    • canUpgrade

      public static boolean canUpgrade(String fromVersion, String toVersion)
      Checks if an upgrade from one version to another is possible.
      Parameters:
      fromVersion - the source version
      toVersion - the target version
      Returns:
      true if the upgrade is possible
    • isEligibleForInference

      public static boolean isEligibleForInference(String modelVersion)
      Checks if a model version is eligible for inference optimizations. Models 4.0.0+ are eligible (4.0.0 has limited inference, 4.1.0+ has full inference).
      Parameters:
      modelVersion - the model version to check
      Returns:
      true if eligible for inference
    • isNewerThan410

      public static boolean isNewerThan410(String modelVersion)
      Checks if a model version is newer than 4.1.0.
      Parameters:
      modelVersion - the model version to check
      Returns:
      true if newer than 4.1.0
    • isVersionGreaterOrEqual

      public static boolean isVersionGreaterOrEqual(String modelVersion, String targetVersion)
      Checks if a model version is greater than or equal to a target version.
      Parameters:
      modelVersion - the model version to check
      targetVersion - the target version to compare against
      Returns:
      true if modelVersion >= targetVersion
    • updateModelVersion

      public static void updateModelVersion(org.jdom2.Document pomDocument, String newVersion)
      Updates the model version element in a POM document.
      Parameters:
      pomDocument - the POM document
      newVersion - the new model version
    • removeModelVersion

      public static boolean removeModelVersion(org.jdom2.Document pomDocument)
      Removes the model version element from a POM document. This is used during inference when the model version can be inferred.
      Parameters:
      pomDocument - the POM document
      Returns:
      true if the element was removed, false if it didn't exist
    • getSchemaLocationForModelVersion

      public static String getSchemaLocationForModelVersion(String modelVersion)
      Gets the schema location for a model version.
      Parameters:
      modelVersion - the model version
      Returns:
      the schema location