diff --git a/auron-build.sh b/auron-build.sh index 2fffcabf5..89eec895f 100755 --- a/auron-build.sh +++ b/auron-build.sh @@ -46,9 +46,11 @@ SUPPORTED_HUDI_VERSIONS=("0.15") # Print script usage information, supported options, and example commands. # ----------------------------------------------------------------------------- print_help() { - echo "Usage: $0 [OPTIONS] " + echo "Usage: $0 [OPTIONS] [--] " echo "Build Auron project with specified Maven profiles" echo + echo "Any arguments after -- are passed to Maven unchanged." + echo echo "Options:" echo " --pre Activate pre-release profile" echo " --release Activate release profile" @@ -57,6 +59,9 @@ print_help() { echo " --sparktests Run spark tests (default: false)" echo " --docker Build in Docker environment (default: false)" echo " --threads Maven build threads (e.g. 1, 4, 1C). Default: local unset, docker 8" + echo " --mvn Maven executable to build with, local builds only" + echo " (default: build/mvn, which downloads Maven)" + echo " --goal Maven goal to run, e.g. package or install (default: install)" IFS=','; echo " --image Docker image to use (e.g. ${SUPPORTED_OS_IMAGES[*]}, default: ${SUPPORTED_OS_IMAGES[*]:0:1})"; unset IFS IFS=','; echo " --sparkver Specify Spark version (e.g. ${SUPPORTED_SPARK_VERSIONS[*]})"; unset IFS IFS=','; echo " --flinkver Specify Flink version (e.g. ${SUPPORTED_FLINK_VERSIONS[*]})"; unset IFS @@ -151,6 +156,7 @@ run_docker_compose_up() { } MVN_CMD="$(dirname "$0")/build/mvn" +MVN_CMD_OVERRIDDEN=false # ----------------------------------------------------------------------------- # Section: Initialize Variables @@ -163,6 +169,7 @@ PRE_PROFILE=false RELEASE_PROFILE=false CLEAN=true SKIP_TESTS=true +MVN_GOAL="install" SPARK_TESTS=false THREADS="" SPARK_VER="" @@ -375,9 +382,35 @@ while [[ $# -gt 0 ]]; do exit 1 fi ;; + --mvn) + if [[ -n "$2" && "$2" != -* ]]; then + MVN_CMD_OVERRIDDEN=true + if ! MVN_CMD="$(command -v "$2")"; then + echo "ERROR: --mvn '$2' is not an executable or a command on PATH" >&2 + exit 1 + fi + shift 2 + else + echo "ERROR: Missing argument for --mvn, specify a path to a Maven executable" >&2 + exit 1 + fi + ;; + --goal) + if [[ -n "$2" && "$2" != -* ]]; then + MVN_GOAL="$2" + shift 2 + else + echo "ERROR: Missing argument for --goal, specify a Maven goal such as package or install" >&2 + exit 1 + fi + ;; -h|--help) print_help ;; + --) + shift + break + ;; --*) echo "ERROR: Unknown option '$1'" >&2 echo "Use '$0 --help' for usage information" >&2 @@ -467,9 +500,9 @@ fi BUILD_ARGS=() if [[ "$SKIP_TESTS" == true ]]; then - BUILD_ARGS+=("install" "-DskipTests") + BUILD_ARGS+=("$MVN_GOAL" "-DskipTests") else - BUILD_ARGS+=("install") + BUILD_ARGS+=("$MVN_GOAL") fi if [[ "$SPARK_TESTS" == true ]]; then @@ -527,7 +560,7 @@ BUILD_INFO_FILE="common/src/main/resources/auron-build-info.properties" mkdir -p "$(dirname "$BUILD_INFO_FILE")" JAVA_VERSION=$(java -version 2>&1 | head -n 1 | awk '{print $3}' | tr -d '"') -PROJECT_VERSION=$(./build/mvn help:evaluate -N -Dexpression=project.version -Pspark-${SPARK_VER} -q -DforceStdout 2>/dev/null) +PROJECT_VERSION=$("$MVN_CMD" help:evaluate -N -Dexpression=project.version -Pspark-${SPARK_VER} -q -DforceStdout 2>/dev/null) RUST_VERSION=$(rustc --version | awk '{print $2}') get_build_info() { @@ -591,6 +624,9 @@ fi # ----------------------------------------------------------------------------- if [[ "$USE_DOCKER" == true ]]; then echo "[INFO] Compiling inside Docker container using image: $IMAGE_NAME" + if [[ "$MVN_CMD_OVERRIDDEN" == true ]]; then + echo "[WARN] --mvn only applies to local builds; the container always uses ./build/mvn" + fi if [[ "$CLEAN" == true ]]; then # Clean the host-side directory that is mounted into the Docker container. # This avoids "device or resource busy" errors when running `mvn clean` inside the container. @@ -599,7 +635,13 @@ if [[ "$USE_DOCKER" == true ]]; then fi echo "[INFO] Compiling inside Docker container..." - export AURON_BUILD_ARGS="${BUILD_ARGS[*]}" + # Forward -D arguments and everything after `--` into the container. + DOCKER_MVN_ARGS=("${BUILD_ARGS[@]}" "${MVN_D_ARGS[@]}" "$@") + AURON_BUILD_ARGS="" + for arg in "${DOCKER_MVN_ARGS[@]}"; do + AURON_BUILD_ARGS+="$(printf '%q' "$arg") " + done + export AURON_BUILD_ARGS="${AURON_BUILD_ARGS% }" export BUILD_CONTEXT="./${IMAGE_NAME}" # Spark 4.x requires JDK 17+, auto-set if not specified if [[ -z "$AURON_JAVA_VERSION" && "$SPARK_VER" == 4.* ]]; then diff --git a/dev/docker-build/docker-compose.yml b/dev/docker-build/docker-compose.yml index e8e938f37..f5c8f2fef 100644 --- a/dev/docker-build/docker-compose.yml +++ b/dev/docker-build/docker-compose.yml @@ -39,5 +39,5 @@ services: source ~/.bashrc && cd /auron && echo "[DOCKER] Running: ./build/mvn $AURON_BUILD_ARGS" && - ./build/mvn $AURON_BUILD_ARGS + eval "./build/mvn $AURON_BUILD_ARGS" '