From f4a022b27a3e155b0351e1b2fd0ae0fc382695fd Mon Sep 17 00:00:00 2001 From: Kevin Sandi Date: Mon, 22 Dec 2025 21:07:39 -0600 Subject: [PATCH] Fix: Add backward compatibility for maven-deploy-plugin Issue-ID: IT-29089 Signed-off-by: Kevin Sandi Change-Id: I6c16cec0391147ee273f2d77adc8e344b0683960 --- .../fix-maven-build-script-3ac753ae181b71c3.yaml | 7 +++++++ shell/maven-build.sh | 22 +++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-maven-build-script-3ac753ae181b71c3.yaml diff --git a/releasenotes/notes/fix-maven-build-script-3ac753ae181b71c3.yaml b/releasenotes/notes/fix-maven-build-script-3ac753ae181b71c3.yaml new file mode 100644 index 00000000..ac2aa395 --- /dev/null +++ b/releasenotes/notes/fix-maven-build-script-3ac753ae181b71c3.yaml @@ -0,0 +1,7 @@ +--- +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. diff --git a/shell/maven-build.sh b/shell/maven-build.sh index 63446d9a..d4b2dddd 100644 --- a/shell/maven-build.sh +++ b/shell/maven-build.sh @@ -17,13 +17,33 @@ echo "---> maven-build.sh" 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 -- 2.16.6