This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-mvnd.git

commit 083a28b7af23f7840d1a38321ba4628492f7fc2b
Author: Guillaume Nodet <gno...@gmail.com>
AuthorDate: Mon Nov 25 09:57:22 2024 +0100

    Fixes --verbose/--debug options (fixes #1208)
---
 .../java-mvnd/org/mvndaemon/mvnd/client/DefaultClient.java    |  8 ++++++--
 .../main/java/org/mvndaemon/mvnd/client/DaemonParameters.java | 11 +++++++++++
 .../src/main/java/org/mvndaemon/mvnd/common/Environment.java  |  6 +++---
 dist/src/main/distro/bin/mvnd-bash-completion.bash            |  2 +-
 4 files changed, 21 insertions(+), 6 deletions(-)

diff --git 
a/client/src/main/java-mvnd/org/mvndaemon/mvnd/client/DefaultClient.java 
b/client/src/main/java-mvnd/org/mvndaemon/mvnd/client/DefaultClient.java
index dfc61897..75d18aa0 100644
--- a/client/src/main/java-mvnd/org/mvndaemon/mvnd/client/DefaultClient.java
+++ b/client/src/main/java-mvnd/org/mvndaemon/mvnd/client/DefaultClient.java
@@ -248,10 +248,10 @@ public class DefaultClient implements Client {
 
         boolean version = Environment.MAVEN_VERSION.hasCommandLineOption(args);
         boolean showVersion = 
Environment.MAVEN_SHOW_VERSION.hasCommandLineOption(args);
-        boolean debug = Environment.MAVEN_DEBUG.hasCommandLineOption(args);
+        boolean verbose = Environment.MAVEN_VERBOSE.hasCommandLineOption(args);
 
         // Print version if needed
-        if (version || showVersion || debug) {
+        if (version || showVersion || verbose) {
             // Print mvnd version
             BuildProperties buildProperties = BuildProperties.getInstance();
             final String mvndVersionString = "Apache Maven Daemon (mvnd) " + 
buildProperties.getVersion() + " "
@@ -337,6 +337,10 @@ public class DefaultClient implements Client {
                     .or(() -> 
Optional.ofNullable(parameters.mavenRepoLocal()).map(Path::toString));
             repo.ifPresent(r -> 
Environment.MAVEN_REPO_LOCAL.addCommandLineOption(args, r));
 
+            if (Environment.MVND_DEBUG.removeCommandLineOption(args) != null) {
+                System.setProperty(Environment.MVND_DEBUG.getProperty(), 
"true");
+            }
+
             String width = 
Optional.ofNullable(Environment.MVND_TERMINAL_WIDTH.removeCommandLineOption(args))
                     .orElseGet(() -> {
                         int w = output.getTerminalWidth();
diff --git 
a/client/src/main/java/org/mvndaemon/mvnd/client/DaemonParameters.java 
b/client/src/main/java/org/mvndaemon/mvnd/client/DaemonParameters.java
index 9d2a773d..c26f6214 100644
--- a/client/src/main/java/org/mvndaemon/mvnd/client/DaemonParameters.java
+++ b/client/src/main/java/org/mvndaemon/mvnd/client/DaemonParameters.java
@@ -338,6 +338,13 @@ public class DaemonParameters {
                 .asBoolean();
     }
 
+    /**
+     * @return <code>true</code> if maven should be executed in debug mode.
+     */
+    public boolean debug() {
+        return 
value(Environment.MVND_DEBUG).orSystemProperty().orDefault().asBoolean();
+    }
+
     /**
      *
      * @return if mvnd should behave as maven
@@ -354,6 +361,10 @@ public class DaemonParameters {
         return derive(b -> b.put(Environment.USER_DIR, newUserDir));
     }
 
+    public DaemonParameters debug(boolean debug) {
+        return derive(b -> b.put(Environment.MVND_DEBUG, debug));
+    }
+
     public DaemonParameters withJdkJavaOpts(String opts, boolean before) {
         String org = 
this.properties.getOrDefault(Environment.JDK_JAVA_OPTIONS.getProperty(), "");
         return derive(b -> b.put(
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java 
b/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java
index 5615d762..d70d637d 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java
@@ -103,8 +103,8 @@ public enum Environment {
     MAVEN_LOG_FILE(null, null, null, OptionType.PATH, Flags.INTERNAL, 
"mvn:-l", "mvn:--log-file"),
     /** Batch mode */
     MAVEN_BATCH_MODE(null, null, null, OptionType.BOOLEAN, Flags.INTERNAL, 
"mvn:-B", "mvn:--batch-mode"),
-    /** Debug */
-    MAVEN_DEBUG(null, null, null, OptionType.BOOLEAN, Flags.INTERNAL, 
"mvn:-X", "mvn:--verbose"),
+    /** Verbose */
+    MAVEN_VERBOSE(null, null, null, OptionType.BOOLEAN, Flags.INTERNAL, 
"mvn:-X", "mvn:--verbose"),
     /** Version */
     MAVEN_VERSION(null, null, null, OptionType.BOOLEAN, Flags.INTERNAL, 
"mvn:-v", "mvn:-version", "mvn:--version"),
     /** Show version */
@@ -166,7 +166,7 @@ public enum Environment {
      * 
<code>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000</code>;
 otherwise the debug argument is
      * not passed to the daemon.
      */
-    MVND_DEBUG("mvnd.debug", null, Boolean.FALSE, OptionType.BOOLEAN, 
Flags.DISCRIMINATING),
+    MVND_DEBUG("mvnd.debug", null, Boolean.FALSE, OptionType.BOOLEAN, 
Flags.DISCRIMINATING, "mvn:--debug"),
     /**
      * The tcp address used to launch the debug mode. Defaults to 
<code>8000</code>, which is similar to
      * <code>localhost:8000</code>.  In order to remote debug from a different 
computer, you need to allow
diff --git a/dist/src/main/distro/bin/mvnd-bash-completion.bash 
b/dist/src/main/distro/bin/mvnd-bash-completion.bash
index 28138416..cce9a82f 100755
--- a/dist/src/main/distro/bin/mvnd-bash-completion.bash
+++ b/dist/src/main/distro/bin/mvnd-bash-completion.bash
@@ -218,7 +218,7 @@ _mvnd()
 
     local mvnd_opts="-1"
     local 
mvnd_long_opts="--color|--completion|--diag|--purge|--serial|--status|--stop"
-    local 
mvnd_properties="-Djava.home|-Djdk.java.options|-Dmaven.multiModuleProjectDirectory|-Dmaven.repo.local|-Dmaven.settings|-Dmvnd.buildTime|-Dmvnd.builder|-Dmvnd.cancelConnectTimeout|-Dmvnd.connectTimeout|-Dmvnd.coreExtensionsExclude|-Dmvnd.daemonStorage|-Dmvnd.debug|-Dmvnd.debug.address|-Dmvnd.duplicateDaemonGracePeriod|-Dmvnd.enableAssertions|-Dmvnd.expirationCheckDelay|-Dmvnd.home|-Dmvnd.idleTimeout|-Dmvnd.jvmArgs|-Dmvnd.keepAlive|-Dmvnd.logPurgePeriod|-Dmvnd.maxHeapSize|-Dmvnd
 [...]
+    local 
mvnd_properties="-Djava.home|-Djdk.java.options|-Dmaven.multiModuleProjectDirectory|-Dmaven.repo.local|-Dmaven.settings|-Dmaven.style.color|-Dmvnd.buildTime|-Dmvnd.builder|-Dmvnd.cancelConnectTimeout|-Dmvnd.connectTimeout|-Dmvnd.coreExtensionsExclude|-Dmvnd.daemonStorage|-Dmvnd.debug|-Dmvnd.debug.address|-Dmvnd.duplicateDaemonGracePeriod|-Dmvnd.enableAssertions|-Dmvnd.expirationCheckDelay|-Dmvnd.home|-Dmvnd.idleTimeout|-Dmvnd.jvmArgs|-Dmvnd.keepAlive|-Dmvnd.logPurgePeriod|-Dmvn
 [...]
     local 
opts="-am|-amd|-B|-C|-c|-cpu|-D|-e|-emp|-ep|-f|-fae|-ff|-fn|-gs|-h|-l|-N|-npr|-npu|-nsu|-o|-P|-pl|-q|-rf|-s|-T|-t|-U|-up|-V|-v|-X|${mvnd_opts}"
     local 
long_opts="--also-make|--also-make-dependents|--batch-mode|--strict-checksums|--lax-checksums|--check-plugin-updates|--define|--errors|--encrypt-master-password|--encrypt-password|--file|--fail-at-end|--fail-fast|--fail-never|--global-settings|--help|--log-file|--non-recursive|--no-plugin-registry|--no-plugin-updates|--no-snapshot-updates|--offline|--activate-profiles|--projects|--quiet|--resume-from|--settings|--threads|--toolchains|--update-snapshots|--update-plugins|--show-v
 [...]
 

Reply via email to