From fda9d83b33eb04b111f8e10140933ab629e6c01b Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 14 Mar 2023 14:36:26 +0100 Subject: [PATCH] Reuse maven scripts and get closer to stock maven --- dist/src/main/distro/bin/mvnd-client.conf | 3 + dist/src/main/distro/bin/mvnd-daemon.conf | 3 + .../main/distro/mvn/bin/{mvn.conf => m2.conf} | 3 + dist/src/main/distro/mvn/bin/mvn | 198 ----------------- dist/src/main/distro/mvn/bin/mvn.cmd | 200 ------------------ dist/src/main/distro/mvn/bin/mvnDebug | 35 --- dist/src/main/distro/mvn/bin/mvnDebug.cmd | 44 ---- 7 files changed, 9 insertions(+), 477 deletions(-) rename dist/src/main/distro/mvn/bin/{mvn.conf => m2.conf} (88%) delete mode 100755 dist/src/main/distro/mvn/bin/mvn delete mode 100644 dist/src/main/distro/mvn/bin/mvn.cmd delete mode 100755 dist/src/main/distro/mvn/bin/mvnDebug delete mode 100644 dist/src/main/distro/mvn/bin/mvnDebug.cmd diff --git a/dist/src/main/distro/bin/mvnd-client.conf b/dist/src/main/distro/bin/mvnd-client.conf index a3ea10183..ed682f0b8 100644 --- a/dist/src/main/distro/bin/mvnd-client.conf +++ b/dist/src/main/distro/bin/mvnd-client.conf @@ -26,5 +26,8 @@ set logback.configurationFile.fallback default ${maven.conf}/logging/logback.xml [plexus.core] load ${maven.conf}/logging load ${maven.home}/lib/mvnd/*.jar +optionally ${maven.home}/lib/ext/redisson/*.jar +optionally ${maven.home}/lib/ext/hazelcast/*.jar optionally ${maven.home}/lib/ext/*.jar +load ${maven.home}/lib/maven-*.jar load ${maven.home}/lib/*.jar diff --git a/dist/src/main/distro/bin/mvnd-daemon.conf b/dist/src/main/distro/bin/mvnd-daemon.conf index 6b2173a08..b387bd2df 100644 --- a/dist/src/main/distro/bin/mvnd-daemon.conf +++ b/dist/src/main/distro/bin/mvnd-daemon.conf @@ -26,5 +26,8 @@ set logback.configurationFile.fallback default ${maven.conf}/logging/logback.xml [plexus.core] load ${maven.conf}/logging load ${maven.home}/lib/mvnd/*.jar +optionally ${maven.home}/lib/ext/redisson/*.jar +optionally ${maven.home}/lib/ext/hazelcast/*.jar optionally ${maven.home}/lib/ext/*.jar +load ${maven.home}/lib/maven-*.jar load ${maven.home}/lib/*.jar diff --git a/dist/src/main/distro/mvn/bin/mvn.conf b/dist/src/main/distro/mvn/bin/m2.conf similarity index 88% rename from dist/src/main/distro/mvn/bin/mvn.conf rename to dist/src/main/distro/mvn/bin/m2.conf index df99d78f6..0cd1f3b41 100644 --- a/dist/src/main/distro/mvn/bin/mvn.conf +++ b/dist/src/main/distro/mvn/bin/m2.conf @@ -24,5 +24,8 @@ set logback.configurationFile.fallback default ${maven.conf}/logging/logback.xml [plexus.core] load ${maven.conf}/logging +optionally ${maven.home}/lib/ext/redisson/*.jar +optionally ${maven.home}/lib/ext/hazelcast/*.jar optionally ${maven.home}/lib/ext/*.jar +load ${maven.home}/lib/maven-*.jar load ${maven.home}/lib/*.jar diff --git a/dist/src/main/distro/mvn/bin/mvn b/dist/src/main/distro/mvn/bin/mvn deleted file mode 100755 index 50395f003..000000000 --- a/dist/src/main/distro/mvn/bin/mvn +++ /dev/null @@ -1,198 +0,0 @@ -#!/bin/sh - -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# ----------------------------------------------------------------------------- -# Apache Maven Startup Script -# -# Environment Variable Prerequisites -# -# 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. -# ----------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -mingw=false; -case "`uname`" in - CYGWIN*) cygwin=true;; - MINGW*) mingw=true;; -esac - -## resolve links - $0 may be a link to Maven's home -PRG="$0" - -# need this for relative symlinks -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi -done - -saveddir=`pwd` - -MAVEN_HOME=`dirname "$PRG"`/.. - -# make it fully qualified -MAVEN_HOME=`cd "$MAVEN_HOME" && pwd` - -cd "$saveddir" - -# For Cygwin, ensure paths are in Unix format before anything is touched -if $cygwin ; then - [ -n "$MAVEN_HOME" ] && - MAVEN_HOME=`cygpath --unix "$MAVEN_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For MinGW, ensure paths are in Unix format before anything is touched -if $mingw ; then - [ -n "$MAVEN_HOME" ] && - MAVEN_HOME=`(cd "$MAVEN_HOME"; pwd)` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`(cd "$JAVA_HOME"; pwd)` - # TODO classpath? -fi - -if [ -z "$JAVA_HOME" ] ; then - JAVACMD="`\\unset -f command; \\command -v java`" -else - JAVACMD="$JAVA_HOME/bin/java" -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "The JAVA_HOME environment variable is not defined correctly," >&2 - echo "this environment variable is needed to run this program." >&2 - exit 1 -fi - -CLASSWORLDS_JAR=`echo "${MAVEN_HOME}"/boot/plexus-classworlds-*.jar` -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - [ -n "$MAVEN_HOME" ] && - MAVEN_HOME=`cygpath --path --windows "$MAVEN_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$CLASSWORLDS_JAR" ] && - CLASSWORLDS_JAR=`cygpath --path --windows "$CLASSWORLDS_JAR"` -fi - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { -( - basedir=`find_file_argument_basedir "$@"` - wdir="${basedir}" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - wdir=`cd "$wdir/.."; pwd` - done - echo "${basedir}" -) -} - -find_file_argument_basedir() { -( - basedir=`pwd` - - found_file_switch=0 - for arg in "$@"; do - if [ ${found_file_switch} -eq 1 ]; then - if [ -d "${arg}" ]; then - basedir=`cd "${arg}" && pwd -P` - elif [ -f "${arg}" ]; then - basedir=`dirname "${arg}"` - basedir=`cd "${basedir}" && pwd -P` - if [ ! -d "${basedir}" ]; then - echo "Directory ${basedir} extracted from the -f/--file command-line argument ${arg} does not exist" >&2 - exit 1 - fi - else - echo "POM file ${arg} specified with the -f/--file command line argument does not exist" >&2 - exit 1 - fi - break - fi - if [ "$arg" = "-f" -o "$arg" = "--file" ]; then - found_file_switch=1 - fi - done - echo "${basedir}" -) -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "`tr -s '\r\n' ' ' < "$1"`" - fi -} - -MAVEN_PROJECTBASEDIR="${MAVEN_BASEDIR:-`find_maven_basedir "$@"`}" -MAVEN_OPTS="`concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config"` $MAVEN_OPTS" - -# For Cygwin, switch project base directory path to Windows format before -# executing Maven otherwise this will cause Maven not to consider it. -if $cygwin ; then - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -export MAVEN_PROJECTBASEDIR - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - $MAVEN_DEBUG_OPTS \ - -classpath "${CLASSWORLDS_JAR}" \ - "-Dlogback.configurationFile=${MAVEN_HOME}/conf/logging/logback.xml" \ - "-Dclassworlds.conf=${MAVEN_HOME}/bin/mvn.conf" \ - "-Dmaven.home=${MAVEN_HOME}" \ - "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${CLASSWORLDS_LAUNCHER} "$@" diff --git a/dist/src/main/distro/mvn/bin/mvn.cmd b/dist/src/main/distro/mvn/bin/mvn.cmd deleted file mode 100644 index 1a75f2979..000000000 --- a/dist/src/main/distro/mvn/bin/mvn.cmd +++ /dev/null @@ -1,200 +0,0 @@ -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. - -@REM ----------------------------------------------------------------------------- -@REM Apache Maven Startup Script -@REM -@REM Environment Variable Prerequisites -@REM -@REM JAVA_HOME Must point at your Java Development Kit installation. -@REM MAVEN_BATCH_ECHO (Optional) Set to 'on' to enable the echoing of the batch commands. -@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 ----------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%"=="on" echo %MAVEN_BATCH_ECHO% - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%"=="" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* -if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%"=="" goto OkJHome -for %%i in (java.exe) do set "JAVACMD=%%~$PATH:i" -goto checkJCmd - -:OkJHome -set "JAVACMD=%JAVA_HOME%\bin\java.exe" - -:checkJCmd -if exist "%JAVACMD%" goto chkMHome - -echo The JAVA_HOME environment variable is not defined correctly, >&2 -echo this environment variable is needed to run this program. >&2 -goto error - -:chkMHome -set "MAVEN_HOME=%~dp0" -set "MAVEN_HOME=%MAVEN_HOME:~0,-5%" -if not "%MAVEN_HOME%"=="" goto checkMCmd -goto error - -:checkMCmd -if exist "%MAVEN_HOME%\bin\mvn.cmd" goto init -goto error -@REM ==== END VALIDATION ==== - -:init - -set MAVEN_CMD_LINE_ARGS=%* - -@REM Find the project basedir, i.e., the directory that contains the directory ".mvn". -@REM Fallback to current working directory if not found. - -set "MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%" -if not "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set "EXEC_DIR=%CD%" -set "WDIR=%EXEC_DIR%" - -@REM Look for the --file switch and start the search for the .mvn directory from the specified -@REM POM location, if supplied. - -set FILE_ARG= -:arg_loop -if "%~1" == "-f" ( - set "FILE_ARG=%~2" - shift - goto process_file_arg -) -if "%~1" == "--file" ( - set "FILE_ARG=%~2" - shift - goto process_file_arg -) -@REM If none of the above, skip the argument -shift -if not "%~1" == "" ( - goto arg_loop -) else ( - goto findBaseDir -) - -:process_file_arg -if "%FILE_ARG%" == "" ( - goto findBaseDir -) -if not exist "%FILE_ARG%" ( - echo POM file "%FILE_ARG%" specified the -f/--file command-line argument does not exist >&2 - goto error -) -if exist "%FILE_ARG%\*" ( - set "POM_DIR=%FILE_ARG%" -) else ( - call :get_directory_from_file "%FILE_ARG%" -) -if not exist "%POM_DIR%" ( - echo Directory "%POM_DIR%" extracted from the -f/--file command-line argument "%FILE_ARG%" does not exist >&2 - goto error -) -set "WDIR=%POM_DIR%" -goto findBaseDir - -:get_directory_from_file -set "POM_DIR=%~dp1" -:stripPomDir -if not "_%POM_DIR:~-1%"=="_\" goto pomDirStripped -set "POM_DIR=%POM_DIR:~0,-1%" -goto stripPomDir -:pomDirStripped -exit /b - -:findBaseDir -cd /d "%WDIR%" -:findBaseDirLoop -if exist "%WDIR%\.mvn" goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set "WDIR=%CD%" -goto findBaseDirLoop - -:baseDirFound -set "MAVEN_PROJECTBASEDIR=%WDIR%" -cd /d "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -if "_%EXEC_DIR:~-1%"=="_\" set "EXEC_DIR=%EXEC_DIR:~0,-1%" -set "MAVEN_PROJECTBASEDIR=%EXEC_DIR%" -cd /d "%EXEC_DIR%" - -:endDetectBaseDir - -set "jvmConfig=\.mvn\jvm.config" -if not exist "%MAVEN_PROJECTBASEDIR%%jvmConfig%" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -for %%i in ("%MAVEN_HOME%"\boot\plexus-classworlds-*) do set CLASSWORLDS_JAR="%%i" -set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -"%JAVACMD%" ^ - %JVM_CONFIG_MAVEN_PROPS% ^ - %MAVEN_OPTS% ^ - %MAVEN_DEBUG_OPTS% ^ - -classpath %CLASSWORLDS_JAR% ^ - "-Dlogback.configurationFile=%MAVEN_HOME%\conf\logging\logback.xml" ^ - "-Dclassworlds.conf=%MAVEN_HOME%\bin\mvn.conf" ^ - "-Dmaven.home=%MAVEN_HOME%" ^ - "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ - %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS% -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" -if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%"=="on" pause - -if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% - -cmd /C exit /B %ERROR_CODE% diff --git a/dist/src/main/distro/mvn/bin/mvnDebug b/dist/src/main/distro/mvn/bin/mvnDebug deleted file mode 100755 index 5f6095a98..000000000 --- a/dist/src/main/distro/mvn/bin/mvnDebug +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh - -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# ----------------------------------------------------------------------------- -# Apache Maven Debug Script -# -# Environment Variable Prerequisites -# -# 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. -# MAVEN_DEBUG_ADDRESS (Optional) Set the debug address. Default value is 8000 -# ----------------------------------------------------------------------------- - -MAVEN_DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${MAVEN_DEBUG_ADDRESS:-8000}" - -echo Preparing to execute Maven in debug mode - -env MAVEN_OPTS="$MAVEN_OPTS" MAVEN_DEBUG_OPTS="$MAVEN_DEBUG_OPTS" "`dirname "$0"`/mvn" "$@" diff --git a/dist/src/main/distro/mvn/bin/mvnDebug.cmd b/dist/src/main/distro/mvn/bin/mvnDebug.cmd deleted file mode 100644 index 6a327ff55..000000000 --- a/dist/src/main/distro/mvn/bin/mvnDebug.cmd +++ /dev/null @@ -1,44 +0,0 @@ -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. - -@REM ----------------------------------------------------------------------------- -@REM Apache Maven Debug Script -@REM -@REM Environment Variable Prerequisites -@REM -@REM JAVA_HOME Must point at your Java Development Kit installation. -@REM MAVEN_BATCH_ECHO (Optional) Set to 'on' to enable the echoing of the batch commands. -@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 MAVEN_DEBUG_ADDRESS (Optional) Set the debug address. Default value is 8000 -@REM ----------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%"=="on" echo %MAVEN_BATCH_ECHO% - -@setlocal - -IF "%MAVEN_DEBUG_ADDRESS%"=="" @set MAVEN_DEBUG_ADDRESS=8000 - -@set MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%MAVEN_DEBUG_ADDRESS% - -@call "%~dp0"mvn.cmd %*