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/01/01 13:11:21 UTC

[maven] branch consistent-logging created (now 7685ebe)

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

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


      at 7685ebe  Use consistent static final loggers

This branch includes the following new commits:

     new da7ed11  Apply consistent log argument quoting for sigle- and multi-valued args
     new 7685ebe  Use consistent static final loggers

The 2 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.



[maven] 02/02: Use consistent static final loggers

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

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

commit 7685ebe00b64fd98eeb90e2d4c0034b80ba8d6c6
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Fri Jan 1 14:10:01 2021 +0100

    Use consistent static final loggers
---
 .../project/collector/MultiModuleCollectionStrategy.java | 10 +++++-----
 .../configuration/SettingsXmlConfigurationProcessor.java | 16 ++++++++--------
 .../apache/maven/cli/logging/BaseSlf4jConfiguration.java |  6 +++---
 .../impl/UnsupportedSlf4jBindingConfiguration.java       |  8 ++++----
 4 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/project/collector/MultiModuleCollectionStrategy.java b/maven-core/src/main/java/org/apache/maven/project/collector/MultiModuleCollectionStrategy.java
index 88c1b8c..4d4413e 100644
--- a/maven-core/src/main/java/org/apache/maven/project/collector/MultiModuleCollectionStrategy.java
+++ b/maven-core/src/main/java/org/apache/maven/project/collector/MultiModuleCollectionStrategy.java
@@ -50,7 +50,7 @@ import java.util.function.Predicate;
 @Singleton
 public class MultiModuleCollectionStrategy implements ProjectCollectionStrategy
 {
-    private final Logger logger = LoggerFactory.getLogger( getClass() );
+    private static final Logger LOGGER = LoggerFactory.getLogger( MultiModuleCollectionStrategy.class );
     private final ModelLocator modelLocator;
     private final ProjectsSelector projectsSelector;
 
@@ -76,7 +76,7 @@ public class MultiModuleCollectionStrategy implements ProjectCollectionStrategy
             }
             else
             {
-                logger.debug( "Multi module project collection failed:{}"
+                LOGGER.debug( "Multi module project collection failed:{}"
                         + "Detected a POM file next to a .mvn folder in a parent directory ({}). "
                         + "Maven assumed that POM file to be the parent of the requested project ({}), but it turned "
                         + "out that it was not. Another project collection strategy will be executed as result.",
@@ -91,7 +91,7 @@ public class MultiModuleCollectionStrategy implements ProjectCollectionStrategy
 
             if ( fallThrough )
             {
-                logger.debug( "Multi module project collection failed:{}"
+                LOGGER.debug( "Multi module project collection failed:{}"
                         + "Detected that one of the modules of this multi module project uses another module as "
                         + "plugin extension which still needed to be built. This is not possible within the same "
                         + "reactor build. Another project collection strategy will be executed as result.",
@@ -114,10 +114,10 @@ public class MultiModuleCollectionStrategy implements ProjectCollectionStrategy
             File multiModuleProjectPom = modelLocator.locatePom( request.getMultiModuleProjectDirectory() );
             if ( !multiModuleProjectPom.exists() )
             {
-                logger.info( "Maven detected that the requested POM file is part of a multi module project, "
+                LOGGER.info( "Maven detected that the requested POM file is part of a multi module project, "
                         + "but could not find a pom.xml file in the multi module root directory '{}'.",
                         request.getMultiModuleProjectDirectory() );
-                logger.info( "The reactor is limited to all projects under: " + request.getPom().getParent() );
+                LOGGER.info( "The reactor is limited to all projects under: " + request.getPom().getParent() );
                 return request.getPom();
             }
 
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java b/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java
index f57d782..5197f32 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java
@@ -71,7 +71,7 @@ public class SettingsXmlConfigurationProcessor
     public static final File DEFAULT_GLOBAL_SETTINGS_FILE =
         new File( System.getProperty( "maven.conf" ), "settings.xml" );
 
-    private final Logger logger = LoggerFactory.getLogger( SettingsXmlConfigurationProcessor.class );
+    private static final Logger LOGGER = LoggerFactory.getLogger( SettingsXmlConfigurationProcessor.class );
 
     @Inject
     private SettingsBuilder settingsBuilder;
@@ -137,9 +137,9 @@ public class SettingsXmlConfigurationProcessor
             request.getEventSpyDispatcher().onEvent( settingsRequest );
         }
 
-        logger.debug( "Reading global settings from '{}'",
+        LOGGER.debug( "Reading global settings from '{}'",
             getLocation( settingsRequest.getGlobalSettingsSource(), settingsRequest.getGlobalSettingsFile() ) );
-        logger.debug( "Reading user settings from '{}'",
+        LOGGER.debug( "Reading user settings from '{}'",
             getLocation( settingsRequest.getUserSettingsSource(), settingsRequest.getUserSettingsFile() ) );
 
         SettingsBuildingResult settingsResult = settingsBuilder.build( settingsRequest );
@@ -151,16 +151,16 @@ public class SettingsXmlConfigurationProcessor
 
         populateFromSettings( request, settingsResult.getEffectiveSettings() );
 
-        if ( !settingsResult.getProblems().isEmpty() && logger.isWarnEnabled() )
+        if ( !settingsResult.getProblems().isEmpty() && LOGGER.isWarnEnabled() )
         {
-            logger.warn( "" );
-            logger.warn( "Some problems were encountered while building the effective settings" );
+            LOGGER.warn( "" );
+            LOGGER.warn( "Some problems were encountered while building the effective settings" );
 
             for ( SettingsProblem problem : settingsResult.getProblems() )
             {
-                logger.warn( "{} @ {}", problem.getMessage(), problem.getLocation() );
+                LOGGER.warn( "{} @ {}", problem.getMessage(), problem.getLocation() );
             }
-            logger.warn( "" );
+            LOGGER.warn( "" );
         }
     }
 
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/BaseSlf4jConfiguration.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/BaseSlf4jConfiguration.java
index 33e9920..33c47c2 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/logging/BaseSlf4jConfiguration.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/BaseSlf4jConfiguration.java
@@ -31,15 +31,15 @@ import org.slf4j.LoggerFactory;
 public class BaseSlf4jConfiguration
     implements Slf4jConfiguration
 {
-    private final Logger logger = LoggerFactory.getLogger( BaseSlf4jConfiguration.class );
+    private static final Logger LOGGER = LoggerFactory.getLogger( BaseSlf4jConfiguration.class );
 
     public void setRootLoggerLevel( Level level )
     {
-        logger.warn( "setRootLoggerLevel: operation not supported" );
+        LOGGER.warn( "setRootLoggerLevel: operation not supported" );
     }
 
     public void activate()
     {
-        logger.warn( "reset(): operation not supported" );
+        LOGGER.warn( "reset(): operation not supported" );
     }
 }
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/UnsupportedSlf4jBindingConfiguration.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/UnsupportedSlf4jBindingConfiguration.java
index 222ab4d..077c674 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/UnsupportedSlf4jBindingConfiguration.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/UnsupportedSlf4jBindingConfiguration.java
@@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
 public class UnsupportedSlf4jBindingConfiguration
     extends BaseSlf4jConfiguration
 {
-    private final Logger logger = LoggerFactory.getLogger( UnsupportedSlf4jBindingConfiguration.class );
+    private static final Logger LOGGER = LoggerFactory.getLogger( UnsupportedSlf4jBindingConfiguration.class );
 
     private String slf4jBinding;
 
@@ -51,8 +51,8 @@ public class UnsupportedSlf4jBindingConfiguration
     @Override
     public void activate()
     {
-        logger.warn( "The SLF4J binding actually used is not supported by Maven: {}", slf4jBinding );
-        logger.warn( "Maven supported bindings are:" );
+        LOGGER.warn( "The SLF4J binding actually used is not supported by Maven: {}", slf4jBinding );
+        LOGGER.warn( "Maven supported bindings are:" );
 
         String ls = System.lineSeparator();
 
@@ -66,7 +66,7 @@ public class UnsupportedSlf4jBindingConfiguration
                 sb.append( ls ).append( "- " ).append( binding );
             }
 
-            logger.warn( sb.toString() );
+            LOGGER.warn( sb.toString() );
         }
     }
 }


[maven] 01/02: Apply consistent log argument quoting for sigle- and multi-valued args

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

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

commit da7ed11cd94436eb13bd4153255cf15499020f25
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Fri Jan 1 14:09:07 2021 +0100

    Apply consistent log argument quoting for sigle- and multi-valued args
---
 .../java/org/apache/maven/graph/DefaultGraphBuilder.java |  2 +-
 .../main/java/org/apache/maven/project/MavenProject.java |  2 +-
 .../maven/project/collector/DefaultProjectsSelector.java |  2 +-
 .../project/collector/MultiModuleCollectionStrategy.java |  8 ++++----
 .../src/main/java/org/apache/maven/cli/MavenCli.java     | 16 ++++++++--------
 .../configuration/SettingsXmlConfigurationProcessor.java |  4 ++--
 .../org/apache/maven/cli/event/ExecutionEventLogger.java |  2 +-
 7 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java b/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
index 14f114d..fb876ac 100644
--- a/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
+++ b/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
@@ -458,7 +458,7 @@ public class DefaultGraphBuilder
 
                     if ( projectsMap.containsKey( pluginKey ) )
                     {
-                        LOGGER.warn( "{} uses {} as extensions, which is not possible within the same reactor build. "
+                        LOGGER.warn( "'{}' uses '{}' as extensions, which is not possible within the same reactor build. "
                             + "This plugin was pulled from the local repository!", project.getName(), plugin.getKey() );
                     }
                 }
diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
index 94dc70a..958df1e 100644
--- a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
+++ b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
@@ -936,7 +936,7 @@ public class MavenProject
         int index = attachedArtifacts.indexOf( artifact );
         if ( index >= 0 )
         {
-            LOGGER.warn( "artifact {} already attached, replace previous instance", artifact );
+            LOGGER.warn( "artifact '{}' already attached, replacing previous instance", artifact );
             attachedArtifacts.set( index, artifact );
         }
         else
diff --git a/maven-core/src/main/java/org/apache/maven/project/collector/DefaultProjectsSelector.java b/maven-core/src/main/java/org/apache/maven/project/collector/DefaultProjectsSelector.java
index 3776c6f..d341d0a 100644
--- a/maven-core/src/main/java/org/apache/maven/project/collector/DefaultProjectsSelector.java
+++ b/maven-core/src/main/java/org/apache/maven/project/collector/DefaultProjectsSelector.java
@@ -74,7 +74,7 @@ public class DefaultProjectsSelector implements ProjectsSelector
             if ( !result.getProblems().isEmpty() && LOGGER.isWarnEnabled() )
             {
                 LOGGER.warn( "" );
-                LOGGER.warn( "Some problems were encountered while building the effective model for {}",
+                LOGGER.warn( "Some problems were encountered while building the effective model for '{}'",
                         result.getProject().getId() );
 
                 for ( ModelProblem problem : result.getProblems() )
diff --git a/maven-core/src/main/java/org/apache/maven/project/collector/MultiModuleCollectionStrategy.java b/maven-core/src/main/java/org/apache/maven/project/collector/MultiModuleCollectionStrategy.java
index 1aab11c..88c1b8c 100644
--- a/maven-core/src/main/java/org/apache/maven/project/collector/MultiModuleCollectionStrategy.java
+++ b/maven-core/src/main/java/org/apache/maven/project/collector/MultiModuleCollectionStrategy.java
@@ -76,7 +76,7 @@ public class MultiModuleCollectionStrategy implements ProjectCollectionStrategy
             }
             else
             {
-                logger.debug( "Multi module project collection failed: {}"
+                logger.debug( "Multi module project collection failed:{}"
                         + "Detected a POM file next to a .mvn folder in a parent directory ({}). "
                         + "Maven assumed that POM file to be the parent of the requested project ({}), but it turned "
                         + "out that it was not. Another project collection strategy will be executed as result.",
@@ -91,7 +91,7 @@ public class MultiModuleCollectionStrategy implements ProjectCollectionStrategy
 
             if ( fallThrough )
             {
-                logger.debug( "Multi module project collection failed: {}"
+                logger.debug( "Multi module project collection failed:{}"
                         + "Detected that one of the modules of this multi module project uses another module as "
                         + "plugin extension which still needed to be built. This is not possible within the same "
                         + "reactor build. Another project collection strategy will be executed as result.",
@@ -115,8 +115,8 @@ public class MultiModuleCollectionStrategy implements ProjectCollectionStrategy
             if ( !multiModuleProjectPom.exists() )
             {
                 logger.info( "Maven detected that the requested POM file is part of a multi module project, "
-                        + "but could not find a pom.xml file in the multi module root directory: '"
-                        + request.getMultiModuleProjectDirectory() + "'. " );
+                        + "but could not find a pom.xml file in the multi module root directory '{}'.",
+                        request.getMultiModuleProjectDirectory() );
                 logger.info( "The reactor is limited to all projects under: " + request.getPom().getParent() );
                 return request.getPom();
             }
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 7b3728e..fd02459 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
@@ -793,7 +793,7 @@ public class MavenCli
         }
         catch ( Exception e )
         {
-            slf4jLogger.warn( "Failed to read extensions descriptor {}: {}", extensionsFile, e.getMessage() );
+            slf4jLogger.warn( "Failed to read extensions descriptor from '{}'", extensionsFile, e );
         }
         return Collections.emptyList();
     }
@@ -821,11 +821,11 @@ public class MavenCli
 
             extRealm.setParentRealm( coreRealm );
 
-            slf4jLogger.debug( "Populating class realm {}", extRealm.getId() );
+            slf4jLogger.debug( "Populating class realm '{}'", extRealm.getId() );
 
             for ( File file : extClassPath )
             {
-                slf4jLogger.debug( "  Included {}", file );
+                slf4jLogger.debug( "  included '{}'", file );
 
                 extRealm.addURL( file.toURI().toURL() );
             }
@@ -874,7 +874,7 @@ public class MavenCli
             {
                 File file = resolveFile( new File( jar ), cliRequest.workingDirectory );
 
-                slf4jLogger.debug( "  Included {}", file );
+                slf4jLogger.debug( "  included '{}'", file );
 
                 jars.add( file );
             }
@@ -1009,12 +1009,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 full debug logging.",
                         buffer().strong( "-X" ) );
             }
 
@@ -1302,9 +1302,9 @@ public class MavenCli
 
         eventSpyDispatcher.onEvent( toolchainsRequest );
 
-        slf4jLogger.debug( "Reading global toolchains from {}",
+        slf4jLogger.debug( "Reading global toolchains from '{}'",
                 getLocation( toolchainsRequest.getGlobalToolchainsSource(), globalToolchainsFile ) );
-        slf4jLogger.debug( "Reading user toolchains from {}",
+        slf4jLogger.debug( "Reading user toolchains from '{}'",
                 getLocation( toolchainsRequest.getUserToolchainsSource(), userToolchainsFile ) );
 
         ToolchainsBuildingResult toolchainsResult = toolchainsBuilder.build( toolchainsRequest );
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java b/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java
index 5c5ce4e..f57d782 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java
@@ -137,9 +137,9 @@ public class SettingsXmlConfigurationProcessor
             request.getEventSpyDispatcher().onEvent( settingsRequest );
         }
 
-        logger.debug( "Reading global settings from {}",
+        logger.debug( "Reading global settings from '{}'",
             getLocation( settingsRequest.getGlobalSettingsSource(), settingsRequest.getGlobalSettingsFile() ) );
-        logger.debug( "Reading user settings from {}",
+        logger.debug( "Reading user settings from '{}'",
             getLocation( settingsRequest.getUserSettingsSource(), settingsRequest.getUserSettingsFile() ) );
 
         SettingsBuildingResult settingsResult = settingsBuilder.build( settingsRequest );
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java
index f3cd858..24652d4 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java
@@ -361,7 +361,7 @@ public class ExecutionEventLogger extends AbstractExecutionListener
     {
         if ( logger.isWarnEnabled() )
         {
-            logger.warn( "Goal {} requires online mode for execution but Maven is currently offline, skipping",
+            logger.warn( "Goal '{}' requires online mode for execution but Maven is currently offline, skipping",
                     event.getMojoExecution().getGoal() );
         }
     }