[Tool] support build maven project in batch mode (#54940)

Signed-off-by: Kevin Xiaohua Cai <caixiaohua@starrocks.com>
This commit is contained in:
Kevin Cai 2025-01-13 14:10:20 +08:00 committed by GitHub
parent a6b14d75ae
commit bee52f8147
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 5 deletions

View File

@ -106,6 +106,8 @@ Usage: $0 <options>
--with-source-file-relative-path {ON|OFF}
build source file with relative path. (default: $WITH_RELATIVE_SRC_PATH)
--without-avx2 build Backend without avx2(instruction)
--with-maven-batch-mode {ON|OFF}
build maven project in batch mode (default: $WITH_MAVEN_BATCH_MODE)
-h,--help Show this help message
Eg.
$0 build all
@ -143,6 +145,7 @@ OPTS=$(getopt \
-l 'with-compress-debug-symbol:' \
-l 'with-source-file-relative-path:' \
-l 'without-avx2' \
-l 'with-maven-batch-mode:' \
-l 'help' \
-- "$@")
@ -169,6 +172,16 @@ BUILD_JAVA_EXT=ON
OUTPUT_COMPILE_TIME=OFF
WITH_TENANN=ON
WITH_RELATIVE_SRC_PATH=ON
# Default to OFF, turn it ON if current shell is non-interactive
WITH_MAVEN_BATCH_MODE=OFF
if [ -x "$(command -v tty)" ] ; then
# has `tty` and `tty` cmd indicates a non-interactive shell.
if ! tty -s >/dev/null 2>&1; then
WITH_MAVEN_BATCH_MODE=ON
fi
fi
MSG=""
MSG_FE="Frontend"
MSG_DPP="Spark Dpp application"
@ -271,6 +284,7 @@ else
--without-avx2) USE_AVX2=OFF; shift ;;
--with-compress-debug-symbol) WITH_COMPRESS=$2 ; shift 2 ;;
--with-source-file-relative-path) WITH_RELATIVE_SRC_PATH=$2 ; shift 2 ;;
--with-maven-batch-mode) WITH_MAVEN_BATCH_MODE=$2 ; shift 2 ;;
-h) HELP=1; shift ;;
--help) HELP=1; shift ;;
-j) PARALLEL=$2; shift 2 ;;
@ -326,6 +340,7 @@ echo "Get params:
OUTPUT_COMPILE_TIME -- $OUTPUT_COMPILE_TIME
WITH_TENANN -- $WITH_TENANN
WITH_RELATIVE_SRC_PATH -- $WITH_RELATIVE_SRC_PATH
WITH_MAVEN_BATCH_MODE -- $WITH_MAVEN_BATCH_MODE
"
check_tool()
@ -367,6 +382,12 @@ else
export LIBRARY_PATH=${JAVA_HOME}/jre/lib/amd64/server/
fi
addon_mvn_opts=""
if [ "x$WITH_MAVEN_BATCH_MODE" = "xON" ] ; then
# this option is only available with mvn >= 3.6
addon_mvn_opts="--batch-mode"
fi
# Clean and build Backend
if [ ${BUILD_BE} -eq 1 ] || [ ${BUILD_FORMAT_LIB} -eq 1 ] ; then
if ! ${CMAKE_CMD} --version; then
@ -458,7 +479,7 @@ if [ ${BUILD_BE} -eq 1 ] || [ ${BUILD_FORMAT_LIB} -eq 1 ] ; then
if [ ${CLEAN} -eq 1 ]; then
${MVN_CMD} clean
fi
${MVN_CMD} package -DskipTests
${MVN_CMD} $addon_mvn_opts package -DskipTests
cd ${STARROCKS_HOME}
else
echo "Skip Building Java Extensions"
@ -488,9 +509,9 @@ if [ ${FE_MODULES}x != ""x ]; then
if [ ${CLEAN} -eq 1 ]; then
${MVN_CMD} clean
fi
${MVN_CMD} package -am -pl ${FE_MODULES} -DskipTests
${MVN_CMD} $addon_mvn_opts package -am -pl ${FE_MODULES} -DskipTests
cd ${STARROCKS_HOME}/java-extensions
${MVN_CMD} package -am -pl hadoop-ext -DskipTests
${MVN_CMD} $addon_mvn_opts package -am -pl hadoop-ext -DskipTests
cd ${STARROCKS_HOME}
fi

View File

@ -21,7 +21,7 @@ ARG BUILD_ROOT
COPY . ${BUILD_ROOT}
WORKDIR ${BUILD_ROOT}
# clean and build Frontend and Spark Dpp application
RUN --mount=type=cache,target=/root/.m2/ STARROCKS_VERSION=${RELEASE_VERSION} BUILD_TYPE=${BUILD_TYPE} MAVEN_OPTS=${MAVEN_OPTS} ./build.sh --fe --clean
RUN --mount=type=cache,target=/root/.m2/ STARROCKS_VERSION=${RELEASE_VERSION} BUILD_TYPE=${BUILD_TYPE} MAVEN_OPTS=${MAVEN_OPTS} ./build.sh --fe --with-maven-batch-mode ON --clean
FROM ${builder} as broker-builder

View File

@ -95,7 +95,7 @@ RUN mkdir -p ${MAVEN_INSTALL_HOME} && cd ${MAVEN_INSTALL_HOME} && \
curl -s -k https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz | tar -xzf - --strip-components=1 && \
ln -s ${MAVEN_INSTALL_HOME}/bin/mvn /usr/bin/mvn
# install clang-format
RUN ARCH=`uname -m` ; if [[ $ARCH == "aarch64" ]] ; then DOWNLOAD_URL=http://cdn-thirdparty.starrocks.com/aarch64/clang-format ; else DOWNLOAD_URL=http://cdn-thirdparty.starrocks.com/clang-format ; fi ; curl -s $DOWNLOAD_URL -o /usr/bin/clang-format && chmod +x /usr/bin/clang-format
RUN ARCH=`uname -m` ; if [ "x$ARCH" == "xaarch64" ] ; then DOWNLOAD_URL=http://cdn-thirdparty.starrocks.com/aarch64/clang-format ; else DOWNLOAD_URL=http://cdn-thirdparty.starrocks.com/clang-format ; fi ; curl -s $DOWNLOAD_URL -o /usr/bin/clang-format && chmod +x /usr/bin/clang-format
ENV STARROCKS_GCC_HOME=${GCC_INSTALL_HOME}
ENV JAVA_HOME=${JDK_INSTALL_HOME}