Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 47 additions & 5 deletions auron-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ SUPPORTED_HUDI_VERSIONS=("0.15")
# Print script usage information, supported options, and example commands.
# -----------------------------------------------------------------------------
print_help() {
echo "Usage: $0 [OPTIONS] <maven build options>"
echo "Usage: $0 [OPTIONS] [--] <maven build 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"
Expand All @@ -57,6 +59,9 @@ print_help() {
echo " --sparktests <true|false> Run spark tests (default: false)"
echo " --docker <true|false> Build in Docker environment (default: false)"
echo " --threads <N|NC> Maven build threads (e.g. 1, 4, 1C). Default: local unset, docker 8"
echo " --mvn <PATH> Maven executable to build with, local builds only"
echo " (default: build/mvn, which downloads Maven)"
echo " --goal <GOAL> Maven goal to run, e.g. package or install (default: install)"
IFS=','; echo " --image <NAME> Docker image to use (e.g. ${SUPPORTED_OS_IMAGES[*]}, default: ${SUPPORTED_OS_IMAGES[*]:0:1})"; unset IFS
IFS=','; echo " --sparkver <VERSION> Specify Spark version (e.g. ${SUPPORTED_SPARK_VERSIONS[*]})"; unset IFS
IFS=','; echo " --flinkver <VERSION> Specify Flink version (e.g. ${SUPPORTED_FLINK_VERSIONS[*]})"; unset IFS
Expand Down Expand Up @@ -151,6 +156,7 @@ run_docker_compose_up() {
}

MVN_CMD="$(dirname "$0")/build/mvn"
MVN_CMD_OVERRIDDEN=false

# -----------------------------------------------------------------------------
# Section: Initialize Variables
Expand All @@ -163,6 +169,7 @@ PRE_PROFILE=false
RELEASE_PROFILE=false
CLEAN=true
SKIP_TESTS=true
MVN_GOAL="install"
SPARK_TESTS=false
THREADS=""
SPARK_VER=""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dev/docker-build/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
'
Loading