diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml
index e990866563..8e02f0cc4b 100644
--- a/apache-maven/pom.xml
+++ b/apache-maven/pom.xml
@@ -83,6 +83,10 @@
org.sonatype.aether
aether-connector-wagon
+
+ org.slf4j
+ slf4j-nop
+
diff --git a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
index 2ddbd45c68..b1c6d9e6ae 100644
--- a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
+++ b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
@@ -198,6 +198,26 @@ private void importMavenApi( Map imports )
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 );
}
/**
diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml
index 4d71019999..76ce3a842c 100644
--- a/maven-embedder/pom.xml
+++ b/maven-embedder/pom.xml
@@ -70,6 +70,10 @@
org.sonatype.plexus
plexus-cipher
+
+ org.slf4j
+ slf4j-api
+
commons-cli
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 d1780acfb4..981b6f8040 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
@@ -59,12 +59,14 @@
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.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 @@ private PlexusContainer container( CliRequest cliRequest )
{
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 );
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLogger.java b/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLogger.java
new file mode 100644
index 0000000000..75f09ab0a6
--- /dev/null
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLogger.java
@@ -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 );
+ }
+
+}
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLoggerFactory.java b/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLoggerFactory.java
new file mode 100644
index 0000000000..cf4f44b2bf
--- /dev/null
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLoggerFactory.java
@@ -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 ) );
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index 19db0abf42..485e5ba9f6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,6 +56,7 @@
1.4.1
1.3
1.13.1
+ 1.6.1
true
apache-maven
@@ -203,6 +204,17 @@
plexus-interpolation
${plexusInterpolationVersion}
+
+ org.slf4j
+ slf4j-api
+ ${slf4jVersion}
+
+
+ org.slf4j
+ slf4j-nop
+ ${slf4jVersion}
+ runtime
+
org.apache.maven.wagon