Class ModelVersionUtils
java.lang.Object
org.apache.maven.cling.invoker.mvnup.goals.ModelVersionUtils
Utility class for handling Maven model version operations during upgrades.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanUpgrade(String fromVersion, String toVersion) Checks if an upgrade from one version to another is possible.static StringdetectModelVersion(org.jdom2.Document pomDocument) Detects the model version from a POM document.static StringgetSchemaLocationForModelVersion(String modelVersion) Gets the schema location for a model version.static booleanisEligibleForInference(String modelVersion) Checks if a model version is eligible for inference optimizations.static booleanisNewerThan410(String modelVersion) Checks if a model version is newer than 4.1.0.static booleanisValidModelVersion(String modelVersion) Checks if a model version is valid for upgrade operations.static booleanisVersionGreaterOrEqual(String modelVersion, String targetVersion) Checks if a model version is greater than or equal to a target version.static booleanremoveModelVersion(org.jdom2.Document pomDocument) Removes the model version element from a POM document.static voidupdateModelVersion(org.jdom2.Document pomDocument, String newVersion) Updates the model version element in a POM document.
-
Method Details
-
detectModelVersion
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
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
-
isEligibleForInference
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
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
Checks if a model version is greater than or equal to a target version.- Parameters:
modelVersion- the model version to checktargetVersion- the target version to compare against- Returns:
- true if modelVersion >= targetVersion
-
updateModelVersion
Updates the model version element in a POM document.- Parameters:
pomDocument- the POM documentnewVersion- 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
-