diff --git a/client/pom.xml b/client/pom.xml index f9808d067..8fb167f92 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -225,7 +225,7 @@ - build + compile-no-fork package diff --git a/dist/src/main/distro/bin/mvnd.cmd b/dist/src/main/distro/bin/mvnd.cmd index 62d29d490..4d1125367 100644 --- a/dist/src/main/distro/bin/mvnd.cmd +++ b/dist/src/main/distro/bin/mvnd.cmd @@ -25,6 +25,12 @@ @REM MAVEN_BATCH_PAUSE (Optional) set to 'on' to wait for a key stroke before ending. @REM MAVEN_OPTS (Optional) Java runtime options used when Maven is executed. @REM MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files. +@REM MVND_CLIENT (Optional) Control how to select mvnd client to communicate with the daemon: +@REM 'auto' (default) - prefer the native client mvnd.exe if it suits the current +@REM OS and processor architecture; otherwise use the pure +@REM Java client. +@REM 'native' - use the native client mvnd.exe +@REM 'jvm' - use the pure Java client @REM ----------------------------------------------------------------------------- @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' @@ -43,6 +49,28 @@ if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* set ERROR_CODE=0 +set "MVND_CMD=%~dp0\mvnd.exe" +if "%MVND_CLIENT%"=="native" goto runNative +if "%MVND_CLIENT%"=="" goto checkNative +if not "%MVND_CLIENT%"=="auto" goto runJvm + +:checkNative +@REM try execute native image +if "%PROCESSOR_ARCHITEW6432%"=="" ( + if not exist "%~dp0\platform-windows-%PROCESSOR_ARCHITECTURE%" goto runJvm +) else ( + if not exist "%~dp0\platform-windows-%PROCESSOR_ARCHITEW6432%" goto runJvm +) +if not exist "%MVND_CMD%" goto runJvm + +:runNative +"%MVND_CMD%" %* +if ERRORLEVEL 1 goto error +goto end + +:runJvm +@REM fallback to pure java version + @REM ==== START VALIDATION ==== if not "%JAVA_HOME%"=="" goto OkJHome for %%i in (java.exe) do set "JAVACMD=%%~$PATH:i" diff --git a/dist/src/main/distro/bin/mvnd.sh b/dist/src/main/distro/bin/mvnd.sh index df821112e..5ac4533a0 100755 --- a/dist/src/main/distro/bin/mvnd.sh +++ b/dist/src/main/distro/bin/mvnd.sh @@ -25,6 +25,11 @@ # JAVA_HOME Must point at your Java Development Kit installation. # MAVEN_OPTS (Optional) Java runtime options used when Maven is executed. # MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files. +# MVND_CLIENT (Optional) Control how to select mvnd client to communicate with the daemon: +# 'auto' (default) - prefer the native client mvnd if it suits the current OS and +# processor architecture; otherwise use the pure Java client. +# 'native' - use the native client mvnd +# 'jvm' - use the pure Java client # ----------------------------------------------------------------------------- if [ -z "$MAVEN_SKIP_RC" ] ; then @@ -43,8 +48,8 @@ fi cygwin=false; mingw=false; case "`uname`" in - CYGWIN*) cygwin=true;; - MINGW*) mingw=true;; + CYGWIN*) cygwin=true native_ext=.exe ;; + MINGW*) mingw=true native_ext=.exe ;; esac ## resolve links - $0 may be a link to Maven's home @@ -89,6 +94,36 @@ if $mingw ; then # TODO classpath? fi +if [ "${MVND_CLIENT:=auto}" = native ]; then + # force execute native image + exec "$MVND_HOME/bin/mvnd${native_ext:-}" "$@" +elif [ "$MVND_CLIENT" = auto ]; then + # try native image + case "$(uname -a)" in + (CYGWIN*|MINGW*) os=windows arch="${PROCESSOR_ARCHITEW6432:-"${PROCESSOR_ARCHITECTURE:-"$(uname -m)"}"}" ;; + (Darwin*x86_64) os=darwin arch=amd64 ;; + (Darwin*arm64) os=darwin arch=aarch64 ;; + (Linux*) os=linux arch=$(uname -m) ;; + (*) os=$(uname) arch=$(uname -m) ;; + esac + [ "${arch-}" != x86_64 ] || arch=amd64 + [ "${arch-}" != AMD64 ] || arch=amd64 + [ "${arch-}" != arm64 ] || arch=aarch64 + + MVND_CMD="$MVND_HOME/bin/mvnd${native_ext:-}" + if [ -e "$MVND_HOME/bin/platform-$os-$arch" ] && [ -x "$MVND_CMD" ]; then + is_native=true + if [ "$os" = linux ]; then + case "$(ldd "$MVND_CMD" 2>&1)" in + (''|*"not found"*) is_native=false ;; + esac + fi + ! $is_native || exec "$MVND_CMD" "$@" + fi +fi + +# fallback to pure java version + if [ -z "$JAVA_HOME" ] ; then JAVACMD="`\\unset -f command; \\command -v java`" else diff --git a/dist/src/main/provisio/maven-distro.xml b/dist/src/main/provisio/maven-distro.xml index 145e2f883..536f348a6 100644 --- a/dist/src/main/provisio/maven-distro.xml +++ b/dist/src/main/provisio/maven-distro.xml @@ -97,6 +97,7 @@ mvnd mvnd.exe +