You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2021/08/01 19:19:02 UTC

[maven] branch MNG-7203 updated (76ee1d6 -> 6fb94b1)

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

michaelo pushed a change to branch MNG-7203
in repository https://gitbox.apache.org/repos/asf/maven.git.


 discard 76ee1d6  [MNG-7203] Introduce a long option --verbose and deprecate --debug
     new 6fb94b1  [MNG-7203] Introduce a long option --verbose and deprecate --debug

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (76ee1d6)
            \
             N -- N -- N   refs/heads/MNG-7203 (6fb94b1)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

[maven] 01/01: [MNG-7203] Introduce a long option --verbose and deprecate --debug

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch MNG-7203
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 6fb94b19daaef923e88a0814e9930bceeb52bec4
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sun Aug 1 21:15:10 2021 +0200

    [MNG-7203] Introduce a long option --verbose and deprecate --debug
    
    This closes #519
---
 .../main/java/org/apache/maven/cli/CLIManager.java  | 11 +++++++++--
 .../main/java/org/apache/maven/cli/CliRequest.java  |  6 +++---
 .../main/java/org/apache/maven/cli/MavenCli.java    | 21 ++++++++++++++-------
 .../java/org/apache/maven/cli/CLIManagerTest.java   |  2 +-
 4 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
index fec2bda..70a9516 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
@@ -46,7 +46,7 @@ public class CLIManager
 
     public static final char QUIET = 'q';
 
-    public static final char DEBUG = 'X';
+    public static final char VERBOSE = 'X';
 
     public static final char ERRORS = 'e';
 
@@ -110,6 +110,10 @@ public class CLIManager
 
     public static final String COLOR = "color";
 
+    /** 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";
+
     protected Options options;
 
     @SuppressWarnings( "checkstyle:linelength" )
@@ -122,7 +126,7 @@ public class CLIManager
         options.addOption( Option.builder( Character.toString( OFFLINE ) ).longOpt( "offline" ).desc( "Work offline" ).build() );
         options.addOption( Option.builder( Character.toString( VERSION ) ).longOpt( "version" ).desc( "Display version information" ).build() );
         options.addOption( Option.builder( Character.toString( QUIET ) ).longOpt( "quiet" ).desc( "Quiet output - only show errors" ).build() );
-        options.addOption( Option.builder( Character.toString( DEBUG ) ).longOpt( "debug" ).desc( "Produce execution debug output" ).build() );
+        options.addOption( Option.builder( Character.toString( VERBOSE ) ).longOpt( "verbose" ).longOpt( "verbose" ).desc( "Produce execution verbose output" ).build() );
         options.addOption( Option.builder( Character.toString( ERRORS ) ).longOpt( "errors" ).desc( "Produce execution error messages" ).build() );
         options.addOption( Option.builder( Character.toString( NON_RECURSIVE ) ).longOpt( "non-recursive" ).desc( "Do not recurse into sub-projects. When used together with -pl, do not recurse into sub-projects of selected aggregators" ).build() );
         options.addOption( Option.builder( Character.toString( UPDATE_SNAPSHOTS ) ).longOpt( "update-snapshots" ).desc( "Forces a check for missing releases and updated snapshots on remote repositories" ).build() );
@@ -153,6 +157,9 @@ public class CLIManager
         options.addOption( Option.builder( BUILDER ).longOpt( "builder" ).hasArg().desc( "The id of the build strategy to use" ).build() );
         options.addOption( Option.builder( NO_TRANSFER_PROGRESS ).longOpt( "no-transfer-progress" ).desc( "Do not display transfer progress when downloading or uploading" ).build() );
         options.addOption( Option.builder().longOpt( COLOR ).hasArg().optionalArg( true ).desc( "Defines the color mode of the output. Supported are 'auto', 'always', 'never'." ).build() );
+
+        // Deprecated
+        options.addOption( Option.builder().longOpt( DEBUG ).desc( "Produce execution verbose output (deprecated; only kept for backward compatibility)" ).build() );
     }
 
     public CommandLine parse( String[] args )
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CliRequest.java b/maven-embedder/src/main/java/org/apache/maven/cli/CliRequest.java
index 7dca591..166d1a1 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/CliRequest.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/CliRequest.java
@@ -42,7 +42,7 @@ public class CliRequest
 
     File multiModuleProjectDirectory;
 
-    boolean debug;
+    boolean verbose;
 
     boolean quiet;
 
@@ -86,9 +86,9 @@ public class CliRequest
         return multiModuleProjectDirectory;
     }
 
-    public boolean isDebug()
+    public boolean isVerbose()
     {
-        return debug;
+        return verbose;
     }
 
     public boolean isQuiet()
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
index 07a9c78..8f5b72f 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
@@ -497,14 +497,15 @@ public class MavenCli
     void logging( CliRequest cliRequest )
     {
         // LOG LEVEL
-        cliRequest.debug = cliRequest.commandLine.hasOption( CLIManager.DEBUG );
-        cliRequest.quiet = !cliRequest.debug && cliRequest.commandLine.hasOption( CLIManager.QUIET );
-        cliRequest.showErrors = cliRequest.debug || cliRequest.commandLine.hasOption( CLIManager.ERRORS );
+        cliRequest.verbose = cliRequest.commandLine.hasOption( CLIManager.VERBOSE )
+                             || cliRequest.commandLine.hasOption( CLIManager.DEBUG );
+        cliRequest.quiet = !cliRequest.verbose && cliRequest.commandLine.hasOption( CLIManager.QUIET );
+        cliRequest.showErrors = cliRequest.verbose || cliRequest.commandLine.hasOption( CLIManager.ERRORS );
 
         slf4jLoggerFactory = LoggerFactory.getILoggerFactory();
         Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration( slf4jLoggerFactory );
 
-        if ( cliRequest.debug )
+        if ( cliRequest.verbose )
         {
             cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_DEBUG );
             slf4jConfiguration.setRootLoggerLevel( Slf4jConfiguration.Level.DEBUG );
@@ -582,11 +583,16 @@ public class MavenCli
                         MavenSlf4jWrapperFactory.class.getName(), slf4jLoggerFactory.getClass().getName() );
             }
         }
+
+        if ( cliRequest.commandLine.hasOption( CLIManager.DEBUG ) )
+        {
+            slf4jLogger.warn("The option '--debug' is deprecated and may be repurposed as Java debug in a future version. Use -X/--verbose instead.");
+        }
     }
 
     private void version( CliRequest cliRequest )
     {
-        if ( cliRequest.debug || cliRequest.commandLine.hasOption( CLIManager.SHOW_VERSION ) )
+        if ( cliRequest.verbose || cliRequest.commandLine.hasOption( CLIManager.SHOW_VERSION ) )
         {
             System.out.println( CLIReportingUtils.showVersion() );
         }
@@ -1034,7 +1040,7 @@ public class MavenCli
             }
             if ( !slf4jLogger.isDebugEnabled() )
             {
-                slf4jLogger.error( "Re-run Maven using the '{}' switch to enable full debug logging.",
+                slf4jLogger.error( "Re-run Maven using the '{}' switch to enable verbose logging.",
                         buffer().strong( "-X" ) );
             }
 
@@ -1606,7 +1612,8 @@ public class MavenCli
             // If we're logging to a file then we don't want the console transfer listener as it will spew
             // download progress all over the place
             //
-            return getConsoleTransferListener( commandLine.hasOption( CLIManager.DEBUG ) );
+            return getConsoleTransferListener( commandLine.hasOption( CLIManager.VERBOSE )
+                                               || commandLine.hasOption( CLIManager.DEBUG ) );
         }
         else
         {
diff --git a/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerTest.java b/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerTest.java
index a3aad6b..68e4c22 100644
--- a/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerTest.java
+++ b/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerTest.java
@@ -42,7 +42,7 @@ public class CLIManagerTest
         throws Exception
     {
         CommandLine cmdLine = cliManager.parse( "-X -Dx=1 -D y=2 test".split( " " ) );
-        assertTrue( cmdLine.hasOption( CLIManager.DEBUG ) );
+        assertTrue( cmdLine.hasOption( CLIManager.VERBOSE ) );
         assertThat( cmdLine.getOptionValues( CLIManager.SET_SYSTEM_PROPERTY )[0], is( "x=1" ) );
         assertThat( cmdLine.getOptionValues( CLIManager.SET_SYSTEM_PROPERTY )[1], is( "y=2" ) );
     }