maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject git commit: added slf4j-simple logging configuration reinitialization to have Core ITs run without errors
Date Sun, 06 Jan 2013 10:50:28 GMT
Updated Branches:
  refs/heads/master 89c252445 -> 72bdc8602


added slf4j-simple logging configuration reinitialization to have
Core ITs run without errors

Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/72bdc860
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/72bdc860
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/72bdc860

Branch: refs/heads/master
Commit: 72bdc8602e5112aa273adc46b06d41c41f0f64a8
Parents: 89c2524
Author: Hervé Boutemy <hboutemy@apache.org>
Authored: Sun Jan 6 11:50:25 2013 +0100
Committer: Hervé Boutemy <hboutemy@apache.org>
Committed: Sun Jan 6 11:50:25 2013 +0100

----------------------------------------------------------------------
 maven-embedder/pom.xml                             |    5 ++
 .../main/java/org/apache/maven/cli/MavenCli.java   |    4 +-
 .../maven/cli/logging/BaseSlf4jConfiguration.java  |    6 +--
 .../maven/cli/logging/Slf4jConfiguration.java      |    7 ++-
 .../cli/logging/impl/Log4j2Configuration.java      |    4 +-
 .../cli/logging/impl/LogbackConfiguration.java     |    4 +-
 .../cli/logging/impl/Slf4jSimpleConfiguration.java |   10 +++--
 .../src/main/java/org/slf4j/MavenSlf4jFriend.java  |   35 +++++++++++++++
 .../org/slf4j/impl/MavenSlf4jSimpleFriend.java     |   32 +++++++++++++
 pom.xml                                            |    3 +-
 10 files changed, 90 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/72bdc860/maven-embedder/pom.xml
----------------------------------------------------------------------
diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml
index 5fb96dc..49a7b57 100644
--- a/maven-embedder/pom.xml
+++ b/maven-embedder/pom.xml
@@ -75,6 +75,11 @@
       <artifactId>slf4j-api</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <optional>true</optional>
+    </dependency>      
+    <dependency>
       <groupId>ch.qos.logback</groupId>
       <artifactId>logback-classic</artifactId>
       <optional>true</optional>

http://git-wip-us.apache.org/repos/asf/maven/blob/72bdc860/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
----------------------------------------------------------------------
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 6737463..5a4710f 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
@@ -342,10 +342,10 @@ public class MavenCli
                 // Ignore
                 //
             }
-
-            slf4jConfiguration.setLoggerFile( logFile ); // is it really useful? redirecting
stdout/stderr isn't sufficient in all cases?
         }
 
+        slf4jConfiguration.activate();
+
         plexusLoggerManager = new Slf4jLoggerManager();
         slf4jLogger = slf4jLoggerFactory.getLogger( this.getClass().getName() );
     }

http://git-wip-us.apache.org/repos/asf/maven/blob/72bdc860/maven-embedder/src/main/java/org/apache/maven/cli/logging/BaseSlf4jConfiguration.java
----------------------------------------------------------------------
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 f82137e..a696184 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
@@ -19,8 +19,6 @@ package org.apache.maven.cli.logging;
  * under the License.
  */
 
-import java.io.File;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -39,8 +37,8 @@ public class BaseSlf4jConfiguration
         logger.warn( "setRootLoggerLevel: operation not supported" );
     }
 
-    public void setLoggerFile( File output )
+    public void activate()
     {
-        logger.warn( "setLoggerFile: operation not supported" );
+        logger.warn( "reset(): operation not supported" );
     }
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/72bdc860/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfiguration.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfiguration.java
b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfiguration.java
index 1ab596f..661c9e3 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfiguration.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfiguration.java
@@ -19,8 +19,6 @@ package org.apache.maven.cli.logging;
  * under the License.
  */
 
-import java.io.File;
-
 /**
  * Interface for configuration operations on loggers, which are not available in slf4j, then
require per-slf4f-binding
  * implementation.
@@ -38,5 +36,8 @@ public interface Slf4jConfiguration
      */
     void setRootLoggerLevel( Level level );
 
-    void setLoggerFile( File output );
+    /**
+     * Activate logging implementation configuration (if necessary).
+     */
+    void activate();
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/72bdc860/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Log4j2Configuration.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Log4j2Configuration.java
b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Log4j2Configuration.java
index c1d1275..9cec3cc 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Log4j2Configuration.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Log4j2Configuration.java
@@ -19,8 +19,6 @@ package org.apache.maven.cli.logging.impl;
  * under the License.
  */
 
-import java.io.File;
-
 import org.apache.maven.cli.logging.BaseSlf4jConfiguration;
 
 /**
@@ -53,7 +51,7 @@ public class Log4j2Configuration
     }
 
     @Override
-    public void setLoggerFile( File output )
+    public void activate()
     {
         // no op
     }

http://git-wip-us.apache.org/repos/asf/maven/blob/72bdc860/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/LogbackConfiguration.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/LogbackConfiguration.java
b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/LogbackConfiguration.java
index 2d60b75..b72940a 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/LogbackConfiguration.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/LogbackConfiguration.java
@@ -19,8 +19,6 @@ package org.apache.maven.cli.logging.impl;
  * under the License.
  */
 
-import java.io.File;
-
 import org.apache.maven.cli.logging.BaseSlf4jConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -55,7 +53,7 @@ public class LogbackConfiguration
     }
 
     @Override
-    public void setLoggerFile( File output )
+    public void activate()
     {
         // no op
     }

http://git-wip-us.apache.org/repos/asf/maven/blob/72bdc860/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSimpleConfiguration.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSimpleConfiguration.java
b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSimpleConfiguration.java
index f463dd8..6a7f385 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSimpleConfiguration.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSimpleConfiguration.java
@@ -19,9 +19,9 @@ package org.apache.maven.cli.logging.impl;
  * under the License.
  */
 
-import java.io.File;
-
 import org.apache.maven.cli.logging.BaseSlf4jConfiguration;
+import org.slf4j.MavenSlf4jFriend;
+import org.slf4j.impl.MavenSlf4jSimpleFriend;
 
 /**
  * Configuration for slf4j-simple.
@@ -53,8 +53,10 @@ public class Slf4jSimpleConfiguration
     }
 
     @Override
-    public void setLoggerFile( File output )
+    public void activate()
     {
-        //System.setProperty( "org.slf4j.simpleLogger.logFile", output.getAbsolutePath()
);
+        // property for root logger level or System.out redirection need to be taken into
account
+        MavenSlf4jFriend.reset();
+        MavenSlf4jSimpleFriend.init();
     }
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/72bdc860/maven-embedder/src/main/java/org/slf4j/MavenSlf4jFriend.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/slf4j/MavenSlf4jFriend.java b/maven-embedder/src/main/java/org/slf4j/MavenSlf4jFriend.java
new file mode 100644
index 0000000..8a43053
--- /dev/null
+++ b/maven-embedder/src/main/java/org/slf4j/MavenSlf4jFriend.java
@@ -0,0 +1,35 @@
+package org.slf4j;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Utility for Maven to access Slf4j internals through package access.
+ * Use with precaution, since this is not normally intended for production use.
+ */
+public class MavenSlf4jFriend
+{
+    /**
+     * Reset Slf4j internal state.
+     */
+    public static void reset()
+    {
+        LoggerFactory.reset();
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven/blob/72bdc860/maven-embedder/src/main/java/org/slf4j/impl/MavenSlf4jSimpleFriend.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/slf4j/impl/MavenSlf4jSimpleFriend.java b/maven-embedder/src/main/java/org/slf4j/impl/MavenSlf4jSimpleFriend.java
new file mode 100644
index 0000000..097ad68
--- /dev/null
+++ b/maven-embedder/src/main/java/org/slf4j/impl/MavenSlf4jSimpleFriend.java
@@ -0,0 +1,32 @@
+package org.slf4j.impl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Utility for Maven to access Slf4j-Simple internals through package access.
+ * Use with precaution, since this is not normally intended for production use.
+ */
+public class MavenSlf4jSimpleFriend
+{
+    public static void init()
+    {
+        SimpleLogger.init();
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven/blob/72bdc860/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 6b0fa21..68dec80 100644
--- a/pom.xml
+++ b/pom.xml
@@ -211,12 +211,13 @@
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-simple</artifactId>
         <version>${slf4jVersion}</version>
-        <scope>runtime</scope>
+        <optional>true</optional>
       </dependency>
       <dependency>
         <groupId>ch.qos.logback</groupId>
         <artifactId>logback-classic</artifactId>
         <version>1.0.7</version>
+        <optional>true</optional>
       </dependency>
       <!--  Wagon -->
       <dependency>


Mime
View raw message