-rf :" + project.getArtifactId() );
}
if ( MavenExecutionRequest.REACTOR_FAIL_NEVER.equals( cliRequest.request.getReactorFailureBehavior() ) )
{
- logger.info( "Build failures were ignored." );
+ slf4jLogger.info( "Build failures were ignored." );
return 0;
}
@@ -667,11 +639,11 @@ public class MavenCli
if ( i == lines.length - 1 && ( showErrors || ( summary.getException() instanceof InternalErrorException ) ) )
{
- logger.error( line, summary.getException() );
+ slf4jLogger.error( line, summary.getException() );
}
else
{
- logger.error( line );
+ slf4jLogger.error( line );
}
}
@@ -683,12 +655,6 @@ public class MavenCli
}
}
- protected ModelProcessor createModelProcessor( PlexusContainer container )
- throws ComponentLookupException
- {
- return container.lookup( ModelProcessor.class );
- }
-
private void settings( CliRequest cliRequest )
throws Exception
{
@@ -740,9 +706,9 @@ public class MavenCli
eventSpyDispatcher.onEvent( settingsRequest );
- logger.debug( "Reading global settings from "
+ slf4jLogger.debug( "Reading global settings from "
+ getSettingsLocation( settingsRequest.getGlobalSettingsSource(), settingsRequest.getGlobalSettingsFile() ) );
- logger.debug( "Reading user settings from "
+ slf4jLogger.debug( "Reading user settings from "
+ getSettingsLocation( settingsRequest.getUserSettingsSource(), settingsRequest.getUserSettingsFile() ) );
SettingsBuildingResult settingsResult = settingsBuilder.build( settingsRequest );
@@ -751,17 +717,17 @@ public class MavenCli
executionRequestPopulator.populateFromSettings( cliRequest.request, settingsResult.getEffectiveSettings() );
- if ( !settingsResult.getProblems().isEmpty() && logger.isWarnEnabled() )
+ if ( !settingsResult.getProblems().isEmpty() && slf4jLogger.isWarnEnabled() )
{
- logger.warn( "" );
- logger.warn( "Some problems were encountered while building the effective settings" );
+ slf4jLogger.warn( "" );
+ slf4jLogger.warn( "Some problems were encountered while building the effective settings" );
for ( SettingsProblem problem : settingsResult.getProblems() )
{
- logger.warn( problem.getMessage() + " @ " + problem.getLocation() );
+ slf4jLogger.warn( problem.getMessage() + " @ " + problem.getLocation() );
}
- logger.warn( "" );
+ slf4jLogger.warn( "" );
}
}
@@ -787,7 +753,7 @@ public class MavenCli
{
if ( commandLine.hasOption( deprecatedOption ) )
{
- logger.warn( "Command line option -" + deprecatedOption
+ slf4jLogger.warn( "Command line option -" + deprecatedOption
+ " is deprecated and will be removed in future Maven versions." );
}
}
@@ -909,14 +875,14 @@ public class MavenCli
}
else if ( request.isInteractiveMode() )
{
- transferListener = new ConsoleMavenTransferListener( System.out );
+ transferListener = new ConsoleMavenTransferListener( slf4jLogger );
}
else
{
- transferListener = new BatchModeMavenTransferListener( System.out );
+ transferListener = new BatchModeMavenTransferListener( slf4jLogger );
}
- ExecutionListener executionListener = new ExecutionEventLogger( logger );
+ ExecutionListener executionListener = new ExecutionEventLogger( slf4jLogger );
executionListener = eventSpyDispatcher.chainListener( executionListener );
String alternatePomFile = null;
@@ -1146,7 +1112,6 @@ public class MavenCli
boolean debug;
boolean quiet;
boolean showErrors = true;
- PrintStream fileStream;
Properties userProperties = new Properties();
Properties systemProperties = new Properties();
MavenExecutionRequest request;
@@ -1172,4 +1137,32 @@ public class MavenCli
}
+ private PrintStreamLogger setupLogger( int loggingLevel )
+ {
+ PrintStreamLogger logger = new PrintStreamLogger( new PrintStreamLogger.Provider()
+ {
+ public PrintStream getStream()
+ {
+ return System.out;
+ }
+ } );
+
+ logger.setThreshold( loggingLevel );
+
+ return logger;
+ }
+
+ //
+ // Customizations available via the CLI
+ //
+
+ protected void customizeContainer( PlexusContainer container )
+ {
+ }
+
+ protected ModelProcessor createModelProcessor( PlexusContainer container )
+ throws ComponentLookupException
+ {
+ return container.lookup( ModelProcessor.class );
+ }
}
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenLoggerManager.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenLoggerManager.java
deleted file mode 100644
index 0d512aee12..0000000000
--- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenLoggerManager.java
+++ /dev/null
@@ -1,162 +0,0 @@
-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 java.util.Locale;
-
-import org.codehaus.plexus.logging.AbstractLoggerManager;
-import org.codehaus.plexus.logging.Logger;
-import org.codehaus.plexus.logging.LoggerManager;
-import org.codehaus.plexus.logging.console.ConsoleLogger;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
-
-/**
- * This is a simple logger manager that will only write the logging statements to the console.
- *
- * Sample configuration:
- *
- *
- * org.codehaus.plexus.logging.ConsoleLoggerManager
- *
- * DEBUG
- *
- *
- *
- *
- * @author Jason van Zyl
- * @author Trygve Laugstøl
- */
-public class MavenLoggerManager
- extends AbstractLoggerManager
- implements LoggerManager, Initializable
-{
- /**
- * Message of this level or higher will be logged.
- *
- * This field is set by the plexus container thus the name is 'threshold'. The field
- * currentThreshold contains the current setting of the threshold.
- */
- private String threshold = "info";
-
- private int currentThreshold;
-
- private Logger logger;
-
- public MavenLoggerManager( Logger logger )
- {
- this.logger = logger;
- }
-
- public void initialize()
- {
- debug( "Initializing ConsoleLoggerManager: " + this.hashCode() + "." );
-
- currentThreshold = parseThreshold( threshold );
-
- if ( currentThreshold == -1 )
- {
- debug( "Could not parse the threshold level: '" + threshold + "', setting to debug." );
- currentThreshold = Logger.LEVEL_DEBUG;
- }
- }
-
- public void setThreshold( int currentThreshold )
- {
- this.currentThreshold = currentThreshold;
- }
-
- public void setThresholds( int currentThreshold )
- {
- this.currentThreshold = currentThreshold;
-
- logger.setThreshold( currentThreshold );
- }
-
- /** @return Returns the threshold. */
- public int getThreshold()
- {
- return currentThreshold;
- }
-
- public void setThreshold( String role,
- String roleHint,
- int threshold )
- {
- }
-
- public int getThreshold( String role,
- String roleHint )
- {
- return currentThreshold;
- }
-
- public Logger getLoggerForComponent( String role,
- String roleHint )
- {
- return logger;
- }
-
- public void returnComponentLogger( String role,
- String roleHint )
- {
- }
-
- public int getActiveLoggerCount()
- {
- return 1;
- }
-
- private int parseThreshold( String text )
- {
- text = text.trim().toLowerCase( Locale.ENGLISH );
-
- if ( text.equals( "debug" ) )
- {
- return ConsoleLogger.LEVEL_DEBUG;
- }
- else if ( text.equals( "info" ) )
- {
- return ConsoleLogger.LEVEL_INFO;
- }
- else if ( text.equals( "warn" ) )
- {
- return ConsoleLogger.LEVEL_WARN;
- }
- else if ( text.equals( "error" ) )
- {
- return ConsoleLogger.LEVEL_ERROR;
- }
- else if ( text.equals( "fatal" ) )
- {
- return ConsoleLogger.LEVEL_FATAL;
- }
-
- return -1;
- }
-
- /**
- * Remove this method and all references when this code is verified.
- *
- * @param msg
- */
- private void debug( String msg )
- {
- }
-}
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
deleted file mode 100644
index 75f09ab0a6..0000000000
--- a/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLogger.java
+++ /dev/null
@@ -1,358 +0,0 @@
-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
deleted file mode 100644
index cf4f44b2bf..0000000000
--- a/maven-embedder/src/main/java/org/apache/maven/cli/PlexusLoggerFactory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-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/maven-embedder/src/main/java/org/apache/maven/cli/DefaultEventSpyContext.java b/maven-embedder/src/main/java/org/apache/maven/cli/event/DefaultEventSpyContext.java
similarity index 96%
rename from maven-embedder/src/main/java/org/apache/maven/cli/DefaultEventSpyContext.java
rename to maven-embedder/src/main/java/org/apache/maven/cli/event/DefaultEventSpyContext.java
index 1c09afbfe1..7c7976ab0f 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/DefaultEventSpyContext.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/event/DefaultEventSpyContext.java
@@ -1,4 +1,4 @@
-package org.apache.maven.cli;
+package org.apache.maven.cli.event;
/*
* Licensed to the Apache Software Foundation (ASF) under one
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/ExecutionEventLogger.java b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java
similarity index 99%
rename from maven-embedder/src/main/java/org/apache/maven/cli/ExecutionEventLogger.java
rename to maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java
index c1c21509cc..819f179e12 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/ExecutionEventLogger.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java
@@ -1,4 +1,4 @@
-package org.apache.maven.cli;
+package org.apache.maven.cli.event;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -30,7 +30,7 @@ import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.logging.Logger;
+import org.slf4j.Logger;
/**
* Logs execution events to a user-supplied logger.
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/PrintStreamLogger.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/PrintStreamLogger.java
similarity index 98%
rename from maven-embedder/src/main/java/org/apache/maven/cli/PrintStreamLogger.java
rename to maven-embedder/src/main/java/org/apache/maven/cli/logging/PrintStreamLogger.java
index 192f960261..53025a0daa 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/PrintStreamLogger.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/PrintStreamLogger.java
@@ -1,4 +1,4 @@
-package org.apache.maven.cli;
+package org.apache.maven.cli.logging;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -34,7 +34,7 @@ public class PrintStreamLogger
extends AbstractLogger
{
- interface Provider
+ public interface Provider
{
PrintStream getStream();
}
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jLogger.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jLogger.java
new file mode 100644
index 0000000000..d467239777
--- /dev/null
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jLogger.java
@@ -0,0 +1,93 @@
+package org.apache.maven.cli.logging;
+
+import org.codehaus.plexus.logging.Logger;
+
+/**
+ * Adapt an SLF4J logger to a Plexus logger.
+ *
+ * @author Jason van Zyl
+ */
+public class Slf4jLogger implements Logger {
+
+ private org.slf4j.Logger logger;
+
+ public Slf4jLogger(org.slf4j.Logger logger) {
+ this.logger = logger;
+ }
+
+ public void debug(String message) {
+ logger.debug(message);
+ }
+
+ public void debug(String message, Throwable throwable) {
+ logger.debug(message, throwable);
+ }
+
+ public boolean isDebugEnabled() {
+ return logger.isDebugEnabled();
+ }
+
+ public void info(String message) {
+ logger.info(message);
+ }
+
+ public void info(String message, Throwable throwable) {
+ logger.info(message, throwable);
+ }
+
+ public boolean isInfoEnabled() {
+ return logger.isInfoEnabled();
+ }
+
+ public void warn(String message) {
+ logger.warn(message);
+ }
+
+ public void warn(String message, Throwable throwable) {
+ logger.warn(message, throwable);
+ }
+
+ public boolean isWarnEnabled() {
+ return logger.isWarnEnabled();
+ }
+
+ public void error(String message) {
+ logger.error(message);
+ }
+
+ public void error(String message, Throwable throwable) {
+ logger.error(message, throwable);
+ }
+
+ public boolean isErrorEnabled() {
+ return logger.isErrorEnabled();
+ }
+
+ public void fatalError(String message) {
+ logger.error(message);
+ }
+
+ public void fatalError(String message, Throwable throwable) {
+ logger.error(message, throwable);
+ }
+
+ public boolean isFatalErrorEnabled() {
+ return logger.isErrorEnabled();
+ }
+
+ public int getThreshold() {
+ return 0;
+ }
+
+ public void setThreshold(int threshold) {
+ }
+
+ public Logger getChildLogger(String name) {
+ return null;
+ }
+
+ public String getName() {
+ return logger.getName();
+ }
+
+}
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jLoggerManager.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jLoggerManager.java
new file mode 100644
index 0000000000..739bdc4bc5
--- /dev/null
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jLoggerManager.java
@@ -0,0 +1,52 @@
+package org.apache.maven.cli.logging;
+
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.logging.LoggerManager;
+import org.slf4j.ILoggerFactory;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Use an SLF4J {@link org.slf4j.ILoggerFactory} as a backing for a Plexus {@link org.codehaus.plexus.logging.LoggerManager}.
+ *
+ * @author Jason van Zyl
+ */
+public class Slf4jLoggerManager implements LoggerManager {
+
+ private ILoggerFactory loggerFactory;
+
+ public Slf4jLoggerManager() {
+ loggerFactory = LoggerFactory.getILoggerFactory();
+ }
+
+ public Logger getLoggerForComponent(String role) {
+ return new Slf4jLogger(loggerFactory.getLogger(role));
+ }
+
+ public Logger getLoggerForComponent(String role, String hint) {
+ return new Slf4jLogger(loggerFactory.getLogger(role + "." + hint));
+ }
+
+ //
+ // Trying to give loggers back is a bad idea. Ceki said so :-)
+ //
+ public void returnComponentLogger(String role) {
+ }
+
+ public void returnComponentLogger(String role, String hint) {
+ }
+
+ public int getThreshold() {
+ return 0;
+ }
+
+ public void setThreshold(int threshold) {
+ }
+
+ public void setThresholds(int threshold) {
+ }
+
+ public int getActiveLoggerCount() {
+ return 0;
+ }
+
+}
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/AbstractMavenTransferListener.java b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java
similarity index 82%
rename from maven-embedder/src/main/java/org/apache/maven/cli/AbstractMavenTransferListener.java
rename to maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java
index 08a44e7145..438d70270a 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/AbstractMavenTransferListener.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java
@@ -1,4 +1,4 @@
-package org.apache.maven.cli;
+package org.apache.maven.cli.transfer;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,11 +19,11 @@ package org.apache.maven.cli;
* under the License.
*/
-import java.io.PrintStream;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
+import org.slf4j.Logger;
import org.sonatype.aether.transfer.AbstractTransferListener;
import org.sonatype.aether.transfer.TransferCancelledException;
import org.sonatype.aether.transfer.TransferEvent;
@@ -33,11 +33,13 @@ public abstract class AbstractMavenTransferListener
extends AbstractTransferListener
{
- protected PrintStream out;
+ protected Logger out;
+ //protected PrintStream out;
- protected AbstractMavenTransferListener( PrintStream out )
+ protected AbstractMavenTransferListener( Logger out )
{
- this.out = ( out != null ) ? out : System.out;
+ this.out = out;
+ //this.out = ( out != null ) ? out : System.out;
}
@Override
@@ -45,7 +47,7 @@ public abstract class AbstractMavenTransferListener
{
String message = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading" : "Downloading";
- out.println( message + ": " + event.getResource().getRepositoryUrl() + event.getResource().getResourceName() );
+ out.info( message + ": " + event.getResource().getRepositoryUrl() + event.getResource().getResourceName() );
}
@Override
@@ -54,7 +56,7 @@ public abstract class AbstractMavenTransferListener
{
TransferResource resource = event.getResource();
- out.println( "[WARNING] " + event.getException().getMessage() + " for " + resource.getRepositoryUrl()
+ out.warn( "[WARNING] " + event.getException().getMessage() + " for " + resource.getRepositoryUrl()
+ resource.getResourceName() );
}
@@ -77,7 +79,7 @@ public abstract class AbstractMavenTransferListener
throughput = " at " + format.format( kbPerSec ) + " KB/sec";
}
- out.println( type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " (" + len
+ out.info( type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " (" + len
+ throughput + ")" );
}
}
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/BatchModeMavenTransferListener.java b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/BatchModeMavenTransferListener.java
similarity index 88%
rename from maven-embedder/src/main/java/org/apache/maven/cli/BatchModeMavenTransferListener.java
rename to maven-embedder/src/main/java/org/apache/maven/cli/transfer/BatchModeMavenTransferListener.java
index 7a165cd6ce..3f026f81f0 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/BatchModeMavenTransferListener.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/BatchModeMavenTransferListener.java
@@ -1,4 +1,6 @@
-package org.apache.maven.cli;
+package org.apache.maven.cli.transfer;
+
+import org.slf4j.Logger;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,12 +21,10 @@ package org.apache.maven.cli;
* under the License.
*/
-import java.io.PrintStream;
-
public class BatchModeMavenTransferListener
extends AbstractMavenTransferListener
{
- public BatchModeMavenTransferListener( PrintStream out )
+ public BatchModeMavenTransferListener( Logger out )
{
super( out );
}
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/ConsoleMavenTransferListener.java b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java
similarity index 94%
rename from maven-embedder/src/main/java/org/apache/maven/cli/ConsoleMavenTransferListener.java
rename to maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java
index c848719aba..5aa39991be 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/ConsoleMavenTransferListener.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java
@@ -1,4 +1,4 @@
-package org.apache.maven.cli;
+package org.apache.maven.cli.transfer;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,10 +19,10 @@ package org.apache.maven.cli;
* under the License.
*/
-import java.io.PrintStream;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import org.slf4j.Logger;
import org.sonatype.aether.transfer.TransferCancelledException;
import org.sonatype.aether.transfer.TransferEvent;
import org.sonatype.aether.transfer.TransferResource;
@@ -40,7 +40,7 @@ public class ConsoleMavenTransferListener
private int lastLength;
- public ConsoleMavenTransferListener( PrintStream out )
+ public ConsoleMavenTransferListener( Logger out )
{
super( out );
}
@@ -70,7 +70,7 @@ public class ConsoleMavenTransferListener
pad( buffer, pad );
buffer.append( '\r' );
- out.print( buffer );
+ out.info( buffer.toString() );
}
private String getStatus( long complete, long total )
@@ -127,7 +127,7 @@ public class ConsoleMavenTransferListener
StringBuilder buffer = new StringBuilder( 64 );
pad( buffer, lastLength );
buffer.append( '\r' );
- out.print( buffer );
+ out.info( buffer.toString() );
}
}
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/QuietMavenTransferListener.java b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/QuietMavenTransferListener.java
similarity index 96%
rename from maven-embedder/src/main/java/org/apache/maven/cli/QuietMavenTransferListener.java
rename to maven-embedder/src/main/java/org/apache/maven/cli/transfer/QuietMavenTransferListener.java
index b9748a33f7..319519cc43 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/QuietMavenTransferListener.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/QuietMavenTransferListener.java
@@ -1,4 +1,4 @@
-package org.apache.maven.cli;
+package org.apache.maven.cli.transfer;
/*
* Licensed to the Apache Software Foundation (ASF) under one
diff --git a/pom.xml b/pom.xml
index af412093e6..948bd7e7d7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -211,10 +211,21 @@
org.slf4j
- slf4j-nop
+ slf4j-simple
${slf4jVersion}
runtime
+<<<<<<< HEAD
+=======
+
+
+ log4j
+ log4j
+ ${log4jVersion}
+ runtime
+
+
+>>>>>>> 4595e08... o Use SLF4J for logging
org.apache.maven.wagon