mirror of https://github.com/apache/maven.git
[MNG-8310] Use --debug option instead of a specific mvnDebug script (#1812)
Use --debug option instead of a specific mvnDebug script. Deprecate existing mvnDebug script, drop newly added mvnencDebug (as it was not released).
This commit is contained in:
parent
9b407d57dc
commit
35a7b31dc4
|
@ -22,10 +22,12 @@
|
|||
#
|
||||
# Environment Variable Prerequisites
|
||||
#
|
||||
# JAVA_HOME (Optional) Points to a Java installation.
|
||||
# MAVEN_ARGS (Optional) Arguments passed to Maven before CLI arguments.
|
||||
# MAVEN_OPTS (Optional) Java runtime options used when Maven is executed.
|
||||
# MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files.
|
||||
# JAVA_HOME (Optional) Points to a Java installation.
|
||||
# MAVEN_ARGS (Optional) Arguments passed to Maven before CLI arguments.
|
||||
# MAVEN_OPTS (Optional) Java runtime options used when Maven is executed.
|
||||
# MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files.
|
||||
# MAVEN_DEBUG_OPTS (Optional) Specify the debug options to use. Default value is "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${MAVEN_DEBUG_ADDRESS}" when --debug is used
|
||||
# MAVEN_DEBUG_ADDRESS (Optional) Set the debug address. Default value is "localhost:8000"
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
@ -167,7 +169,6 @@ MAVEN_PROJECTBASEDIR="`find_maven_basedir "$@"`"
|
|||
MAVEN_OPTS="$MAVEN_OPTS `concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config"`"
|
||||
LAUNCHER_JAR=`echo "$MAVEN_HOME"/boot/plexus-classworlds-*.jar`
|
||||
LAUNCHER_CLASS=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
MAVEN_MAIN_CLASS=${MAVEN_MAIN_CLASS:=org.apache.maven.cling.MavenCling}
|
||||
|
||||
# For Cygwin and MinGW, switch paths to Windows format before running java(1) command
|
||||
if $cygwin || $mingw ; then
|
||||
|
@ -179,6 +180,36 @@ if $cygwin || $mingw ; then
|
|||
MAVEN_PROJECTBASEDIR=`cygpath --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
handle_args() {
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--debug)
|
||||
if [ -z "$MAVEN_DEBUG_OPTS" ] ; then
|
||||
MAVEN_DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${MAVEN_DEBUG_ADDRESS:-localhost:8000}"
|
||||
else
|
||||
echo "Ignoring --debug option as MAVEN_DEBUG_OPTS is already set"
|
||||
fi
|
||||
;;
|
||||
--yjp)
|
||||
if [ ! -f "$YJPLIB" ]; then
|
||||
echo "Error: Unable to autodetect the YJP library location. Please set YJPLIB variable" >&2
|
||||
exit 1
|
||||
fi
|
||||
MAVEN_OPTS="-agentpath:$YJPLIB=onexit=snapshot,onexit=memory,tracing,onlylocal $MAVEN_OPTS"
|
||||
;;
|
||||
--enc)
|
||||
MAVEN_MAIN_CLASS="org.apache.maven.cling.MavenEncCling"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
handle_args "$@"
|
||||
MAVEN_MAIN_CLASS=${MAVEN_MAIN_CLASS:=org.apache.maven.cling.MavenCling}
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
$MAVEN_DEBUG_OPTS \
|
||||
|
|
|
@ -174,6 +174,34 @@ for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do s
|
|||
@REM do not let MAVEN_PROJECTBASEDIR end with a single backslash which would escape the double quote. This happens when .mvn at drive root.
|
||||
if "_%MAVEN_PROJECTBASEDIR:~-1%"=="_\" set "MAVEN_PROJECTBASEDIR=%MAVEN_PROJECTBASEDIR%\"
|
||||
|
||||
if "%MAVEN_DEBUG_ADDRESS%"=="" set MAVEN_DEBUG_ADDRESS=localhost:8000
|
||||
|
||||
goto endHandleArgs
|
||||
:handleArgs
|
||||
if "%~1"=="--debug" (
|
||||
if "%MAVEN_DEBUG_OPTS%"=="" (
|
||||
set "MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%MAVEN_DEBUG_ADDRESS%"
|
||||
)
|
||||
) else if "%~1"=="--yjp" (
|
||||
if not exist "%YJPLIB%" (
|
||||
echo Error: Unable to autodetect the YJP library location. Please set YJPLIB variable >&2
|
||||
exit /b 1
|
||||
)
|
||||
set "MAVEN_OPTS=-agentpath:%YJPLIB%=onexit=snapshot,onexit=memory,tracing,onlylocal %MAVEN_OPTS%"
|
||||
) else if "%~1"=="--enc" (
|
||||
set "MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenEncCling"
|
||||
)
|
||||
exit /b 0
|
||||
|
||||
:processArgs
|
||||
if "%~1"=="" exit /b 0
|
||||
call :handleArgs %1
|
||||
shift
|
||||
goto processArgs
|
||||
|
||||
:endHandleArgs
|
||||
call :processArgs %*
|
||||
|
||||
for %%i in ("%MAVEN_HOME%"\boot\plexus-classworlds-*) do set LAUNCHER_JAR="%%i"
|
||||
set LAUNCHER_CLASS=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
if "%MAVEN_MAIN_CLASS%"=="" @set MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenCling
|
||||
|
|
|
@ -28,8 +28,5 @@
|
|||
# MAVEN_DEBUG_ADDRESS (Optional) Set the debug address. Default value is localhost:8000
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
MAVEN_DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${MAVEN_DEBUG_ADDRESS:-localhost:8000}"
|
||||
|
||||
echo Preparing to execute Maven in debug mode
|
||||
|
||||
env MAVEN_OPTS="$MAVEN_OPTS" MAVEN_DEBUG_OPTS="$MAVEN_DEBUG_OPTS" "`dirname "$0"`/mvn" "$@"
|
||||
echo "This script is deprecated for removal, please use 'mvn --debug' instead"
|
||||
"`dirname "$0"`/mvn" --debug "$@"
|
||||
|
|
|
@ -37,8 +37,5 @@ title %0
|
|||
|
||||
@setlocal
|
||||
|
||||
if "%MAVEN_DEBUG_ADDRESS%"=="" @set MAVEN_DEBUG_ADDRESS=localhost:8000
|
||||
|
||||
@set MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%MAVEN_DEBUG_ADDRESS%
|
||||
|
||||
@call "%~dp0"mvn.cmd %*
|
||||
echo "This script is deprecated for removal, please use 'mvn --debug' instead"
|
||||
@call "%~dp0"mvn.cmd --debug %*
|
||||
|
|
|
@ -27,4 +27,4 @@
|
|||
# MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
env MAVEN_MAIN_CLASS="org.apache.maven.cling.MavenEncCling" "`dirname "$0"`/mvn" "$@"
|
||||
"`dirname "$0"`/mvn" --enc "$@"
|
||||
|
|
|
@ -36,6 +36,4 @@ title %0
|
|||
|
||||
@setlocal
|
||||
|
||||
@set MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenEncCling
|
||||
|
||||
@call "%~dp0"mvn.cmd %*
|
||||
@call "%~dp0"mvn.cmd --enc %*
|
||||
|
|
|
@ -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 (Optional) Points to a Java 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 localhost:8000
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
MAVEN_DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${MAVEN_DEBUG_ADDRESS:-localhost:8000}"
|
||||
|
||||
echo Preparing to execute Maven in debug mode
|
||||
|
||||
env MAVEN_OPTS="$MAVEN_OPTS" MAVEN_DEBUG_OPTS="$MAVEN_DEBUG_OPTS" "`dirname "$0"`/mvnenc" "$@"
|
|
@ -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 (Optional) Points to a Java 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 localhost: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=localhost:8000
|
||||
|
||||
@set MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%MAVEN_DEBUG_ADDRESS%
|
||||
|
||||
@call "%~dp0"mvnenc.cmd %*
|
|
@ -27,9 +27,5 @@
|
|||
# MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
if [ ! -f "$YJPLIB" ]; then
|
||||
echo "Error: Unable to autodetect the YJP library location. Please set YJPLIB variable" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
env MAVEN_OPTS="-agentpath:$YJPLIB=onexit=snapshot,onexit=memory,tracing,onlylocal $MAVEN_OPTS" "`dirname "$0"`/mvn" "$@"
|
||||
echo "This script is deprecated for removal, please use 'mvn --yjp' instead"
|
||||
"`dirname "$0"`/mvn" --yjp "$@"
|
||||
|
|
|
@ -131,10 +131,9 @@ public class CLIManager {
|
|||
|
||||
public static final String IGNORE_TRANSITIVE_REPOSITORIES = "itr";
|
||||
|
||||
/** This option is deprecated and may be repurposed as Java debug in a future version.
|
||||
* Use {@code -X,--verbose} instead. */
|
||||
@Deprecated
|
||||
public static final String DEBUG = "debug";
|
||||
public static final String ENC = "enc";
|
||||
public static final String YJP = "yjp";
|
||||
|
||||
protected Options options;
|
||||
protected final Set<Option> usedDeprecatedOptions = new LinkedHashSet<>();
|
||||
|
@ -339,6 +338,20 @@ public class CLIManager {
|
|||
.desc("If set, Maven will ignore remote repositories introduced by transitive dependencies.")
|
||||
.build());
|
||||
|
||||
// Parameters handled by script
|
||||
options.addOption(Option.builder()
|
||||
.longOpt(DEBUG)
|
||||
.desc("Launch the JVM in debug mode (script option).")
|
||||
.build());
|
||||
options.addOption(Option.builder()
|
||||
.longOpt(ENC)
|
||||
.desc("Launch the Maven Encryption tool (script option).")
|
||||
.build());
|
||||
options.addOption(Option.builder()
|
||||
.longOpt(YJP)
|
||||
.desc("Launch the JVM with Yourkit profiler (script option).")
|
||||
.build());
|
||||
|
||||
// Adding this back to make Maven fail if used
|
||||
options.addOption(Option.builder("llr")
|
||||
.longOpt("legacy-local-repository")
|
||||
|
@ -350,15 +363,6 @@ public class CLIManager {
|
|||
.build());
|
||||
|
||||
// Deprecated
|
||||
options.addOption(Option.builder()
|
||||
.longOpt(DEBUG)
|
||||
.desc("<deprecated> Produce execution verbose output.")
|
||||
.deprecated(DeprecatedAttributes.builder()
|
||||
.setForRemoval(true)
|
||||
.setSince("4.0.0")
|
||||
.setDescription("Use -X,--verbose instead.")
|
||||
.get())
|
||||
.build());
|
||||
options.addOption(Option.builder(ALTERNATE_GLOBAL_SETTINGS)
|
||||
.longOpt("global-settings")
|
||||
.desc("<deprecated> Alternate path for the global settings file.")
|
||||
|
|
|
@ -26,6 +26,17 @@ import java.util.List;
|
|||
*/
|
||||
public class CleanArgument {
|
||||
public static String[] cleanArgs(String[] args) {
|
||||
try {
|
||||
return doCleanArgs(args);
|
||||
} catch (RuntimeException e) {
|
||||
for (String a : args) {
|
||||
System.out.println("Arg: '" + a + "'");
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] doCleanArgs(String[] args) {
|
||||
List<String> cleaned = new ArrayList<>();
|
||||
|
||||
StringBuilder currentArg = null;
|
||||
|
@ -49,7 +60,9 @@ public class CleanArgument {
|
|||
if (addedToBuffer && arg.endsWith("\"")) {
|
||||
// if we're building an argument, keep doing so.
|
||||
// if this is the case of "-Dfoo=bar", then we need to adjust the buffer.
|
||||
currentArg.setLength(currentArg.length() - 1);
|
||||
if (!currentArg.isEmpty()) {
|
||||
currentArg.setLength(currentArg.length() - 1);
|
||||
}
|
||||
|
||||
cleaned.add(currentArg.toString());
|
||||
|
||||
|
|
|
@ -25,6 +25,15 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
/**
|
||||
*/
|
||||
class CleanArgumentTest {
|
||||
|
||||
@Test
|
||||
void cleanArgs() {
|
||||
String[] args = {
|
||||
"\"",
|
||||
};
|
||||
CleanArgument.cleanArgs(args);
|
||||
}
|
||||
|
||||
@Test
|
||||
void cleanArgsShouldRemoveWrongSurroundingQuotes() {
|
||||
String[] args = {"\"-Dfoo=bar", "\"-Dfoo2=bar two\""};
|
||||
|
|
Loading…
Reference in New Issue