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:23 UTC

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

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() );
         }
     }
 }