--- /dev/null
+---
+fixes:
+ - |
+ Add backward compatibility for older versions of maven-deploy-plugin
+ that do not support the new syntax for altDeploymentRepository.
+ If the plugin version is older than 3.X use the legacy syntax
+ "staging::default::file" to avoid build failures.
set -xe -o pipefail
set +u
+# Determine deployment repository format based on maven-deploy-plugin version
+# Version 3+ uses simplified format without ::default::
+plugin_version=$($MVN help:describe -Dplugin=org.apache.maven.plugins:maven-deploy-plugin -Ddetail \
+ --global-settings "$GLOBAL_SETTINGS_FILE" 2>/dev/null \
+ | grep "^Version:" | awk '{print $2}' || echo "2.8.2")
+
+if [[ "${plugin_version%%.*}" -lt 3 ]]; then # Compare only major version number
+ # Disable SC2016 because we don't want $WORKSPACE to be expanded here.
+ # shellcheck disable=SC2016
+ alt_repo='-DaltDeploymentRepository=staging::default::file:"$WORKSPACE"/m2repo'
+else
+ # Disable SC2016 because we don't want $WORKSPACE to be expanded here.
+ # shellcheck disable=SC2016
+ # Disable SC2089 because the embedded quotes are intentional.
+ # shellcheck disable=SC2089
+ alt_repo='-DaltDeploymentRepository=staging::file:"$WORKSPACE"/m2repo'
+fi
+
export MAVEN_OPTS
# Disable SC2086 because we want to allow word splitting for $MAVEN_* parameters.
# shellcheck disable=SC2086
+# Disable SC2090 because the embedded quotes are intentional.
+# shellcheck disable=SC2090
$MVN $MAVEN_GOALS \
-e \
--global-settings "$GLOBAL_SETTINGS_FILE" \
--settings "$SETTINGS_FILE" \
- -DaltDeploymentRepository=staging::file:"$WORKSPACE"/m2repo \
+ $alt_repo \
$MAVEN_OPTIONS $MAVEN_PARAMS