This is an automated email from the ASF dual-hosted git repository.
jiayu pushed a commit to branch release-process
in repository https://gitbox.apache.org/repos/asf/sedona.git
The following commit(s) were added to refs/heads/release-process by this push:
new b236169c36 Implement Maven path detection and wrapper creation
b236169c36 is described below
commit b236169c36f73bb3bcd10446b7dabcd0268303c3
Author: Jia Yu <[email protected]>
AuthorDate: Mon Sep 8 00:21:54 2025 -0700
Implement Maven path detection and wrapper creation
Added functions to find Maven installation and create a Maven wrapper for
specific Java versions.
---
docs/community/publish.md | 120 +++++++++++++++++++++++++++++++++-------------
1 file changed, 87 insertions(+), 33 deletions(-)
diff --git a/docs/community/publish.md b/docs/community/publish.md
index e2d37a1f28..99da15d2d0 100644
--- a/docs/community/publish.md
+++ b/docs/community/publish.md
@@ -132,40 +132,86 @@ get_java_version() {
fi
}
-# Function to set JAVA_HOME based on Java version
-set_java_home() {
- local java_version=$1
- if [[ "$java_version" == "17" ]]; then
- # Try to find Java 17 installation
- if command -v /usr/libexec/java_home >/dev/null 2>&1; then
- export JAVA_HOME=$(/usr/libexec/java_home -v 17 2>/dev/null ||
/usr/libexec/java_home -v 1.17 2>/dev/null || echo "")
- fi
- if [[ -z "$JAVA_HOME" ]]; then
- echo "Warning: Java 17 not found, using system default"
- else
- echo "Using Java 17: $JAVA_HOME"
- fi
- else
- # Try to find Java 11 installation
- if command -v /usr/libexec/java_home >/dev/null 2>&1; then
- export JAVA_HOME=$(/usr/libexec/java_home -v 11 2>/dev/null ||
/usr/libexec/java_home -v 1.11 2>/dev/null || echo "")
- fi
- if [[ -z "$JAVA_HOME" ]]; then
- echo "Warning: Java 11 not found, using system default"
- else
- echo "Using Java 11: $JAVA_HOME"
- fi
+# Function to find Maven installation path
+find_maven_path() {
+ # Try different methods to find Maven
+ local mvn_path=""
+
+ # Method 1: Check if mvn is in PATH
+ if command -v mvn >/dev/null 2>&1; then
+ mvn_path=$(command -v mvn)
+ fi
+
+ # Method 2: Check common Homebrew locations
+ if [[ -z "$mvn_path" ]]; then
+ for version_dir in /opt/homebrew/Cellar/maven/*/libexec/bin/mvn; do
+ if [[ -x "$version_dir" ]]; then
+ mvn_path="$version_dir"
+ break
+ fi
+ done
+ fi
+
+ # Method 3: Check /usr/local (older Homebrew installations)
+ if [[ -z "$mvn_path" ]]; then
+ for version_dir in /usr/local/Cellar/maven/*/libexec/bin/mvn; do
+ if [[ -x "$version_dir" ]]; then
+ mvn_path="$version_dir"
+ break
+ fi
+ done
fi
+
+ # Method 4: Check system locations
+ if [[ -z "$mvn_path" ]]; then
+ for path in /usr/bin/mvn /usr/local/bin/mvn; do
+ if [[ -x "$path" ]]; then
+ mvn_path="$path"
+ break
+ fi
+ done
+ fi
+
+ if [[ -z "$mvn_path" ]]; then
+ echo "ERROR: Could not find Maven installation" >&2
+ echo "Please ensure Maven is installed and available in PATH or in
standard locations" >&2
+ exit 1
+ fi
+
+ echo "$mvn_path"
+}
- # Verify Java version using Maven
- echo "Verifying Java version with Maven..."
- local mvn_java_version=$(mvn --version | grep "Java version" | sed 's/.*Java
version: \([0-9]*\).*/\1/')
- if [[ "$mvn_java_version" != "$java_version" ]]; then
- echo "ERROR: Maven is using Java $mvn_java_version, but expected Java
$java_version"
- echo "Please ensure the correct Java version is installed and JAVA_HOME is
set properly"
+# Function to create Maven wrapper with specific Java version
+create_mvn_wrapper() {
+ local java_version=$1
+ local mvn_wrapper="/tmp/mvn-java${java_version}"
+ local mvn_path=$(find_maven_path)
+
+ echo "Using Maven at: $mvn_path" >&2
+
+ # Create a wrapper script that sets JAVA_HOME and executes Maven
+ cat > "$mvn_wrapper" << EOF
+#!/bin/bash
+JAVA_HOME="\${JAVA_HOME:-\$(/usr/libexec/java_home -v ${java_version})}" exec
"${mvn_path}" "\$@"
+EOF
+
+ chmod +x "$mvn_wrapper"
+ echo "$mvn_wrapper"
+}
+
+# Function to verify Java version using Maven wrapper
+verify_java_version() {
+ local mvn_wrapper=$1
+ local expected_java_version=$2
+
+ echo "Verifying Java version with Maven wrapper..."
+ local mvn_java_version=$($mvn_wrapper --version | grep "Java version" | sed
's/.*Java version: \([0-9]*\).*/\1/')
+ if [[ "$mvn_java_version" != "$expected_java_version" ]]; then
+ echo "ERROR: Maven wrapper is using Java $mvn_java_version, but expected
Java $expected_java_version"
+ echo "Please ensure the correct Java version is installed"
exit 1
fi
- echo "✓ Verified: Maven is using Java $mvn_java_version"
+ echo "✓ Verified: Maven wrapper is using Java $mvn_java_version"
}
# Iterate through Spark and Scala versions
@@ -174,16 +220,24 @@ for SPARK in "${SPARK_VERSIONS[@]}"; do
JAVA_VERSION=$(get_java_version $SPARK)
echo "Running release:perform for Spark $SPARK and Scala $SCALA with Java
$JAVA_VERSION..."
- # Set appropriate Java version
- set_java_home $JAVA_VERSION
+ # Create Maven wrapper with appropriate Java version
+ MVN_WRAPPER=$(create_mvn_wrapper $JAVA_VERSION)
+ echo "Created Maven wrapper: $MVN_WRAPPER"
+
+ # Verify Java version
+ verify_java_version $MVN_WRAPPER $JAVA_VERSION
- mvn
org.apache.maven.plugins:maven-release-plugin:$MAVEN_PLUGIN_VERSION:perform \
+ # Execute Maven with the wrapper
+ $MVN_WRAPPER
org.apache.maven.plugins:maven-release-plugin:$MAVEN_PLUGIN_VERSION:perform \
-DconnectionUrl=scm:git:file://$(pwd) \
-Dtag=$TAG \
-Dresume=false \
-Darguments="-DskipTests -Dspark=$SPARK -Dscala=$SCALA" \
-Dspark=$SPARK \
-Dscala=$SCALA
+
+ # Clean up the wrapper
+ rm -f $MVN_WRAPPER
done
done