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 20:35:03 UTC

[maven] branch MNG-7203 updated (437fbc9 -> a2a3df3)

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 437fbc9  Reduce repition
 discard e201764  Make checkstyle happy
 discard 924f9a7  Unify message
 discard 790202b  Unify message
 discard f5078a8  Make checkstyle happy
 discard 6fb94b1  [MNG-7203] Introduce a long option --verbose and deprecate --debug
     new a2a3df3  [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   (437fbc9)
            \
             N -- N -- N   refs/heads/MNG-7203 (a2a3df3)

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] 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 a2a3df3d02d0a0c7a977d94087f4c6313e8c5a32
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
---
 .../profiles/activation/FileProfileActivator.java  |  2 +-
 .../internal/aether/LoggingRepositoryListener.java |  2 +-
 .../lifecycle/internal/builder/BuilderCommon.java  |  3 ++-
 .../project/artifact/MavenMetadataSource.java      |  2 +-
 .../main/java/org/apache/maven/cli/CLIManager.java | 12 ++++++++--
 .../main/java/org/apache/maven/cli/CliRequest.java |  6 ++---
 .../main/java/org/apache/maven/cli/MavenCli.java   | 27 ++++++++++++++--------
 .../java/org/apache/maven/cli/CLIManagerTest.java  |  2 +-
 8 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/maven-compat/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java b/maven-compat/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java
index e7044f5..586f57f 100644
--- a/maven-compat/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java
+++ b/maven-compat/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java
@@ -97,7 +97,7 @@ public class FileProfileActivator
                 else
                 {
                     logger.warn( "Failed to interpolate missing file location for profile activator: " + fileString
-                        + ". Run in debug mode (-X) for more information." );
+                        + ", enable verbose output (-X) for more details" );
                 }
             }
         }
diff --git a/maven-core/src/main/java/org/apache/maven/internal/aether/LoggingRepositoryListener.java b/maven-core/src/main/java/org/apache/maven/internal/aether/LoggingRepositoryListener.java
index 67dca47..ba8c657 100644
--- a/maven-core/src/main/java/org/apache/maven/internal/aether/LoggingRepositoryListener.java
+++ b/maven-core/src/main/java/org/apache/maven/internal/aether/LoggingRepositoryListener.java
@@ -128,7 +128,7 @@ class LoggingRepositoryListener
         }
         else
         {
-            logger.warn( buffer + ", enable debug logging for more details" );
+            logger.warn( buffer + ", enable verbose output (-X) for more details" );
         }
     }
 
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/BuilderCommon.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/BuilderCommon.java
index c3aed10..d16b27d 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/BuilderCommon.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/BuilderCommon.java
@@ -157,7 +157,8 @@ public class BuilderCommon
                     {
                         logger.warn( unsafePlugin.getId() );
                     }
-                    logger.warn( "Enable debug to see more precisely which goals are not marked @threadSafe." );
+                    logger.warn( "Enable verbose output (-X) to see more precisely which goals are not marked"
+                            + " @threadSafe." );
                 }
                 logger.warn( "*****************************************************************" );
             }
diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
index f0eefc2..271e6d6 100644
--- a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
+++ b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
@@ -623,7 +623,7 @@ public class MavenMetadataSource
                         message =
                             "Invalid POM for " + artifact.getId()
                                 + ", transitive dependencies (if any) will not be available"
-                                + ", enable debug logging for more details";
+                                + ", enable verbose output (-X) for more details";
                     }
 
                     if ( logger.isDebugEnabled() )
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..463edaa 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,11 @@ 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 +127,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 +158,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..042ba40 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,17 @@ 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() );
         }
@@ -1029,12 +1036,12 @@ public class MavenCli
 
             if ( !cliRequest.showErrors )
             {
-                slf4jLogger.error( "To see the full stack trace of the errors, re-run Maven with the '{}' switch.",
+                slf4jLogger.error( "To see the full stack trace of the errors, re-run Maven with the '{}' switch",
                         buffer().strong( "-e" ) );
             }
             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 output",
                         buffer().strong( "-X" ) );
             }
 
@@ -1368,6 +1375,7 @@ public class MavenCli
         CommandLine commandLine = cliRequest.commandLine;
         String workingDirectory = cliRequest.workingDirectory;
         boolean quiet = cliRequest.quiet;
+        boolean verbose = cliRequest.verbose;
         request.setShowErrors( cliRequest.showErrors ); // default: false
         File baseDirectory = new File( workingDirectory, "" ).getAbsoluteFile();
 
@@ -1384,7 +1392,7 @@ public class MavenCli
         request.setUserProperties( cliRequest.userProperties );
         request.setMultiModuleProjectDirectory( cliRequest.multiModuleProjectDirectory );
         request.setPom( determinePom( commandLine, workingDirectory, baseDirectory ) );
-        request.setTransferListener( determineTransferListener( quiet, commandLine, request ) );
+        request.setTransferListener( determineTransferListener( quiet, verbose, commandLine, request ) );
         request.setExecutionListener( determineExecutionListener() );
 
         if ( ( request.getPom() != null ) && ( request.getPom().getParentFile() != null ) )
@@ -1593,6 +1601,7 @@ public class MavenCli
     }
 
     private TransferListener determineTransferListener( final boolean quiet,
+                                                        final boolean verbose,
                                                         final CommandLine commandLine,
                                                         final MavenExecutionRequest request )
     {
@@ -1606,7 +1615,7 @@ 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( verbose );
         }
         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" ) );
     }