FWIW, we are using sfl4j and logback as part of m2e embedded maven
runtime for over a year now without any major issues. There was a
problem with older IBM JVMs [1], but it is fixed now in slf4j (and
in IBM code too, as far as I understand).

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=338252

--
Regards,
Igor


On 12-09-03 3:10 AM, Mark Struberg wrote:
whats the reason for the slf4j bridge?

This is kown to trash old plugins which use log4j because it clashes
with it's namespace and only partly implements the log4j classes.

I personally ind slf4j nice, but for older projects which use
commons-logging or log4j already (and where you cant fiddle around
with their sources) this broke way too many things for me. Why is
this needed at all? Has nothing to do with JSR-330.

LieGrue, strub >



----- Original Message -----
From: "jvan...@apache.org" <jvan...@apache.org>
To: comm...@maven.apache.org
Cc:
Sent: Monday, September 3, 2012 3:07 AM
Subject: svn commit: r1380105 - in /maven/maven-3/trunk: ./ apache-maven/ 
maven-core/src/main/java/org/apache/maven/classrealm/ maven-embedder/ 
maven-embedder/src/main/java/org/apache/maven/cli/

Author: jvanzyl
Date: Mon Sep  3 01:07:31 2012
New Revision: 1380105

URL: http://svn.apache.org/viewvc?rev=1380105&view=rev
Log:
o Enabled support and discovery of JSR-330 components

o Added Slf4j logger factory to support generic JSR-330 logging

o Exported Guice package for components that access Guice (or better it's
injector) directly

Widen export of Guice packages (not ideal, need to look into ways to avoid this)

o use specific exports

o for now we will attempt to hide all of Guice in plugin realms and we'll do
a bit of testing

closes #3

Added:

maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLogger.java

maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLoggerFactory.java
Modified:
     maven/maven-3/trunk/apache-maven/pom.xml

maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
     maven/maven-3/trunk/maven-embedder/pom.xml

maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
     maven/maven-3/trunk/pom.xml

Modified: maven/maven-3/trunk/apache-maven/pom.xml
URL:
http://svn.apache.org/viewvc/maven/maven-3/trunk/apache-maven/pom.xml?rev=1380105&r1=1380104&r2=1380105&view=diff
==============================================================================
--- maven/maven-3/trunk/apache-maven/pom.xml (original)
+++ maven/maven-3/trunk/apache-maven/pom.xml Mon Sep  3 01:07:31 2012
@@ -83,6 +83,10 @@
        <groupId>org.sonatype.aether</groupId>
        <artifactId>aether-connector-wagon</artifactId>
      </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-nop</artifactId>
+    </dependency>
    </dependencies>

    <build>

Modified:
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
URL:
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java?rev=1380105&r1=1380104&r2=1380105&view=diff
==============================================================================
---
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
(original)
+++
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
Mon Sep  3 01:07:31 2012
@@ -198,6 +198,26 @@ public class DefaultClassRealmManager
          imports.put(
"org.codehaus.plexus.util.xml.pull.XmlPullParser", coreRealm );
          imports.put(
"org.codehaus.plexus.util.xml.pull.XmlPullParserException", coreRealm
);
          imports.put(
"org.codehaus.plexus.util.xml.pull.XmlSerializer", coreRealm );
+
+        // javax.inject, sisu-inject (JSR-330)
+        imports.put( "javax.inject.*", coreRealm );
+        imports.put( "javax.enterprise.inject.*", coreRealm );
+        imports.put( "org.sonatype.inject.*", coreRealm );
+        imports.put( "org.slf4j.*", coreRealm );
+
+        // com.google
+        //
+        // We may potentially want to export these, but right now I'm not
sure that anything Guice specific needs
+        // to be made available to plugin authors. If we find people are
getting fancy and want to take advantage
+        // of Guice specifics we can expose that later. Really some testing
needs to be done to see full hiding
+        // of Guice has any impact on what we may categorize as a standard
JSR-330 based Tesla/Maven plugin.
+        //
+        // imports.put( "com.google.inject.*", coreRealm );
+        // imports.put( "com.google.inject.binder.*", coreRealm );
+        // imports.put( "com.google.inject.matcher.*", coreRealm );
+        // imports.put( "com.google.inject.name.*", coreRealm );
+        // imports.put( "com.google.inject.spi.*", coreRealm );
+        // imports.put( "com.google.inject.util.*", coreRealm );
      }

      /**

Modified: maven/maven-3/trunk/maven-embedder/pom.xml
URL:
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-embedder/pom.xml?rev=1380105&r1=1380104&r2=1380105&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-embedder/pom.xml (original)
+++ maven/maven-3/trunk/maven-embedder/pom.xml Mon Sep  3 01:07:31 2012
@@ -70,6 +70,10 @@
        <groupId>org.sonatype.plexus</groupId>
        <artifactId>plexus-cipher</artifactId>
      </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
      <!-- CLI -->
      <dependency>
        <groupId>commons-cli</groupId>

Modified:
maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
URL:
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java?rev=1380105&r1=1380104&r2=1380105&view=diff
==============================================================================
---
maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
(original)
+++
maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
Mon Sep  3 01:07:31 2012
@@ -59,12 +59,14 @@ import org.apache.maven.settings.buildin
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.DefaultContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
+import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.classworlds.ClassWorld;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import
org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.ILoggerFactory;
import org.sonatype.aether.transfer.TransferListener;
import org.sonatype.plexus.components.cipher.DefaultPlexusCipher;
import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher;
@@ -72,6 +74,8 @@ import org.sonatype.plexus.components.se
import org.sonatype.plexus.components.sec.dispatcher.SecUtil;
import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity;

+import com.google.inject.AbstractModule;
+
// TODO: push all common bits back to plexus cli and prepare for transition to
Guice. We don't need 50 ways to make CLIs

/**
@@ -372,17 +376,29 @@ public class MavenCli
          {
              logger = setupLogger( cliRequest );

+            final MavenLoggerManager loggerManager = new MavenLoggerManager(
logger ) ;
+
              ContainerConfiguration cc = new DefaultContainerConfiguration()
                  .setClassWorld( cliRequest.classWorld )
                  .setRealm( setupContainerRealm( cliRequest ) )
+                .setClassPathScanning( PlexusConstants.SCANNING_INDEX )
+                .setAutoWiring( true )
                  .setName( "maven" );

-            container = new DefaultPlexusContainer( cc );
+            container = new DefaultPlexusContainer( cc, new AbstractModule()
+            {
+
+                protected void configure()
+                {
+                    bind( ILoggerFactory.class ).toInstance( new
PlexusLoggerFactory( loggerManager ) );
+                }
+
+            } );

              // NOTE: To avoid inconsistencies, we'll use the TCCL
exclusively for lookups
              container.setLookupRealm( null );

-            container.setLoggerManager( new MavenLoggerManager( logger ) );
+            container.setLoggerManager( loggerManager );

              customizeContainer( container );


Added:
maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLogger.java
URL:
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLogger.java?rev=1380105&view=auto
==============================================================================
---
maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLogger.java
(added)
+++
maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLogger.java
Mon Sep  3 01:07:31 2012
@@ -0,0 +1,358 @@
+package org.apache.maven.cli;
+
+/*
+ * 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.
+ */
+
+import org.slf4j.Logger;
+import org.slf4j.Marker;
+import org.slf4j.helpers.FormattingTuple;
+import org.slf4j.helpers.MessageFormatter;
+
+/**
+ * A Slf4j logger bridged onto a Plexus logger.
+ */
+class PlexusLogger
+    implements Logger
+{
+
+    private final org.codehaus.plexus.logging.Logger logger;
+
+    public PlexusLogger( org.codehaus.plexus.logging.Logger logger )
+    {
+        this.logger = logger;
+    }
+
+    public String getName()
+    {
+        return logger.getName();
+    }
+
+    public boolean isTraceEnabled()
+    {
+        return isDebugEnabled();
+    }
+
+    public void trace( String msg )
+    {
+        debug( msg );
+    }
+
+    public void trace( String format, Object arg )
+    {
+        debug( format, arg );
+    }
+
+    public void trace( String format, Object arg1, Object arg2 )
+    {
+        debug( format, arg1, arg2 );
+    }
+
+    public void trace( String format, Object[] argArray )
+    {
+        debug( format, argArray );
+    }
+
+    public void trace( String msg, Throwable t )
+    {
+        debug( msg, t );
+    }
+
+    public boolean isTraceEnabled( Marker marker )
+    {
+        return isTraceEnabled();
+    }
+
+    public void trace( Marker marker, String msg )
+    {
+        trace( msg );
+    }
+
+    public void trace( Marker marker, String format, Object arg )
+    {
+        trace( format, arg );
+    }
+
+    public void trace( Marker marker, String format, Object arg1, Object arg2 )
+    {
+        trace( format, arg1, arg2 );
+    }
+
+    public void trace( Marker marker, String format, Object[] argArray )
+    {
+        trace( format, argArray );
+    }
+
+    public void trace( Marker marker, String msg, Throwable t )
+    {
+        trace( msg, t );
+    }
+
+    public boolean isDebugEnabled()
+    {
+        return logger.isDebugEnabled();
+    }
+
+    public void debug( String msg )
+    {
+        logger.debug( msg );
+    }
+
+    public void debug( String format, Object arg )
+    {
+        FormattingTuple ft = MessageFormatter.format( format, arg );
+        logger.debug( ft.getMessage(), ft.getThrowable() );
+    }
+
+    public void debug( String format, Object arg1, Object arg2 )
+    {
+        FormattingTuple ft = MessageFormatter.format( format, arg1, arg2 );
+        logger.debug( ft.getMessage(), ft.getThrowable() );
+    }
+
+    public void debug( String format, Object[] argArray )
+    {
+        FormattingTuple ft = MessageFormatter.arrayFormat( format, argArray );
+        logger.debug( ft.getMessage(), ft.getThrowable() );
+    }
+
+    public void debug( String msg, Throwable t )
+    {
+        logger.debug( msg, t );
+    }
+
+    public boolean isDebugEnabled( Marker marker )
+    {
+        return isDebugEnabled();
+    }
+
+    public void debug( Marker marker, String msg )
+    {
+        debug( msg );
+    }
+
+    public void debug( Marker marker, String format, Object arg )
+    {
+        debug( format, arg );
+    }
+
+    public void debug( Marker marker, String format, Object arg1, Object arg2 )
+    {
+        debug( format, arg1, arg2 );
+    }
+
+    public void debug( Marker marker, String format, Object[] argArray )
+    {
+        debug( format, argArray );
+    }
+
+    public void debug( Marker marker, String msg, Throwable t )
+    {
+        debug( msg, t );
+    }
+
+    public boolean isInfoEnabled()
+    {
+        return logger.isInfoEnabled();
+    }
+
+    public void info( String msg )
+    {
+        logger.info( msg );
+    }
+
+    public void info( String format, Object arg )
+    {
+        FormattingTuple ft = MessageFormatter.format( format, arg );
+        logger.info( ft.getMessage(), ft.getThrowable() );
+    }
+
+    public void info( String format, Object arg1, Object arg2 )
+    {
+        FormattingTuple ft = MessageFormatter.format( format, arg1, arg2 );
+        logger.info( ft.getMessage(), ft.getThrowable() );
+    }
+
+    public void info( String format, Object[] argArray )
+    {
+        FormattingTuple ft = MessageFormatter.arrayFormat( format, argArray );
+        logger.info( ft.getMessage(), ft.getThrowable() );
+    }
+
+    public void info( String msg, Throwable t )
+    {
+        logger.info( msg, t );
+    }
+
+    public boolean isInfoEnabled( Marker marker )
+    {
+        return isInfoEnabled();
+    }
+
+    public void info( Marker marker, String msg )
+    {
+        info( msg );
+    }
+
+    public void info( Marker marker, String format, Object arg )
+    {
+        info( format, arg );
+    }
+
+    public void info( Marker marker, String format, Object arg1, Object arg2 )
+    {
+        info( format, arg1, arg2 );
+    }
+
+    public void info( Marker marker, String format, Object[] argArray )
+    {
+        info( format, argArray );
+    }
+
+    public void info( Marker marker, String msg, Throwable t )
+    {
+        info( msg, t );
+    }
+
+    public boolean isWarnEnabled()
+    {
+        return logger.isWarnEnabled();
+    }
+
+    public void warn( String msg )
+    {
+        logger.warn( msg );
+    }
+
+    public void warn( String format, Object arg )
+    {
+        FormattingTuple ft = MessageFormatter.format( format, arg );
+        logger.warn( ft.getMessage(), ft.getThrowable() );
+    }
+
+    public void warn( String format, Object arg1, Object arg2 )
+    {
+        FormattingTuple ft = MessageFormatter.format( format, arg1, arg2 );
+        logger.warn( ft.getMessage(), ft.getThrowable() );
+    }
+
+    public void warn( String format, Object[] argArray )
+    {
+        FormattingTuple ft = MessageFormatter.arrayFormat( format, argArray );
+        logger.warn( ft.getMessage(), ft.getThrowable() );
+    }
+
+    public void warn( String msg, Throwable t )
+    {
+        logger.warn( msg, t );
+    }
+
+    public boolean isWarnEnabled( Marker marker )
+    {
+        return isWarnEnabled();
+    }
+
+    public void warn( Marker marker, String msg )
+    {
+        warn( msg );
+    }
+
+    public void warn( Marker marker, String format, Object arg )
+    {
+        warn( format, arg );
+    }
+
+    public void warn( Marker marker, String format, Object arg1, Object arg2 )
+    {
+        warn( format, arg1, arg2 );
+    }
+
+    public void warn( Marker marker, String format, Object[] argArray )
+    {
+        warn( format, argArray );
+    }
+
+    public void warn( Marker marker, String msg, Throwable t )
+    {
+        warn( msg, t );
+    }
+
+    public boolean isErrorEnabled()
+    {
+        return logger.isErrorEnabled();
+    }
+
+    public void error( String msg )
+    {
+        logger.error( msg );
+    }
+
+    public void error( String format, Object arg )
+    {
+        FormattingTuple ft = MessageFormatter.format( format, arg );
+        logger.error( ft.getMessage(), ft.getThrowable() );
+    }
+
+    public void error( String format, Object arg1, Object arg2 )
+    {
+        FormattingTuple ft = MessageFormatter.format( format, arg1, arg2 );
+        logger.error( ft.getMessage(), ft.getThrowable() );
+    }
+
+    public void error( String format, Object[] argArray )
+    {
+        FormattingTuple ft = MessageFormatter.arrayFormat( format, argArray );
+        logger.error( ft.getMessage(), ft.getThrowable() );
+    }
+
+    public void error( String msg, Throwable t )
+    {
+        logger.error( msg, t );
+    }
+
+    public boolean isErrorEnabled( Marker marker )
+    {
+        return isErrorEnabled();
+    }
+
+    public void error( Marker marker, String msg )
+    {
+        error( msg );
+    }
+
+    public void error( Marker marker, String format, Object arg )
+    {
+        error( format, arg );
+    }
+
+    public void error( Marker marker, String format, Object arg1, Object arg2 )
+    {
+        error( format, arg1, arg2 );
+    }
+
+    public void error( Marker marker, String format, Object[] argArray )
+    {
+        error( format, argArray );
+    }
+
+    public void error( Marker marker, String msg, Throwable t )
+    {
+        error( msg, t );
+    }
+
+}

Added:
maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLoggerFactory.java
URL:
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLoggerFactory.java?rev=1380105&view=auto
==============================================================================
---
maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLoggerFactory.java
(added)
+++
maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLoggerFactory.java
Mon Sep  3 01:07:31 2012
@@ -0,0 +1,50 @@
+package org.apache.maven.cli;
+
+/*
+ * 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.
+ */
+
+import org.codehaus.plexus.logging.LoggerManager;
+import org.slf4j.ILoggerFactory;
+import org.slf4j.Logger;
+
+/**
+ * A Slf4j logger factory bridged onto a Plexus logger manager.
+ */
+public class PlexusLoggerFactory
+    implements ILoggerFactory
+{
+
+    private LoggerManager loggerManager;
+
+    public PlexusLoggerFactory( LoggerManager loggerManager )
+    {
+        this.loggerManager = loggerManager;
+    }
+
+    public void setLoggerManager( LoggerManager loggerManager )
+    {
+        this.loggerManager = loggerManager;
+    }
+
+    public Logger getLogger( String name )
+    {
+        return new PlexusLogger( loggerManager.getLoggerForComponent( name,
null ) );
+    }
+
+}

Modified: maven/maven-3/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/maven/maven-3/trunk/pom.xml?rev=1380105&r1=1380104&r2=1380105&view=diff
==============================================================================
--- maven/maven-3/trunk/pom.xml (original)
+++ maven/maven-3/trunk/pom.xml Mon Sep  3 01:07:31 2012
@@ -56,6 +56,7 @@
      <modelloVersion>1.4.1</modelloVersion>
      <jxpathVersion>1.3</jxpathVersion>
      <aetherVersion>1.13.1</aetherVersion>
+    <slf4jVersion>1.6.1</slf4jVersion>

<maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
      <!-- Control the name of the distribution and information output by mvn
-->
      <distributionId>apache-maven</distributionId>
@@ -203,6 +204,17 @@
          <artifactId>plexus-interpolation</artifactId>
          <version>${plexusInterpolationVersion}</version>
        </dependency>
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-api</artifactId>
+        <version>${slf4jVersion}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-nop</artifactId>
+        <version>${slf4jVersion}</version>
+        <scope>runtime</scope>
+      </dependency>
        <!--  Wagon -->
        <dependency>
          <groupId>org.apache.maven.wagon</groupId>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org

Reply via email to