Fix: Add backward compatibility for maven-deploy-plugin 22/74022/7 v0.92.10
authorKevin Sandi <ksandi@contractor.linuxfoundation.org>
Tue, 23 Dec 2025 03:07:39 +0000 (21:07 -0600)
committerKevin Sandi <ksandi@contractor.linuxfoundation.org>
Tue, 23 Dec 2025 23:01:11 +0000 (17:01 -0600)
Issue-ID: IT-29089
Signed-off-by: Kevin Sandi <ksandi@contractor.linuxfoundation.org>
Change-Id: I6c16cec0391147ee273f2d77adc8e344b0683960

releasenotes/notes/fix-maven-build-script-3ac753ae181b71c3.yaml [new file with mode: 0644]
shell/maven-build.sh

diff --git a/releasenotes/notes/fix-maven-build-script-3ac753ae181b71c3.yaml b/releasenotes/notes/fix-maven-build-script-3ac753ae181b71c3.yaml
new file mode 100644 (file)
index 0000000..ac2aa39
--- /dev/null
@@ -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.
index 63446d9..d4b2ddd 100644 (file)
@@ -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