mirror of https://github.com/apache/maven.git
o Use SLF4J for logging
Conflicts: pom.xml git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1396842 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
22df629f97
commit
a23f7cfd10
|
@ -85,7 +85,7 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-nop</artifactId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -5,3 +5,4 @@ set maven.home default ${user.home}/m2
|
|||
[plexus.core]
|
||||
optionally ${maven.home}/lib/ext/*.jar
|
||||
load ${maven.home}/lib/*.jar
|
||||
load ${maven.home}/conf/logging
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
org.slf4j.simpleLogger.defaultLogLevel = info
|
||||
org.slf4j.simpleLogger.showDateTime=false
org.slf4j.simpleLogger.showThreadName=false
org.slf4j.simpleLogger.showLogName=false
org.slf4j.simpleLogger.logFile=System.out
|
||||
org.slf4j.simpleLogger.levelInBrackets=true
|
|
@ -37,30 +37,7 @@ under the License.
|
|||
<excludes>
|
||||
<exclude>org.codehaus.plexus:plexus-classworlds</exclude>
|
||||
<exclude>junit:junit</exclude>
|
||||
<exclude>log4j:log4j</exclude>
|
||||
<exclude>commons-logging:commons-logging-api</exclude>
|
||||
|
||||
<!--exclude>org.codehaus.plexus:plexus-classworlds</exclude>
|
||||
<exclude>org.codehaus.plexus:plexus-component-api</exclude>
|
||||
<exclude>classworlds:classworlds</exclude>
|
||||
<exclude>junit:junit</exclude>
|
||||
<exclude>jmock:jmock</exclude>
|
||||
<exclude>xml-apis:xml-apis</exclude>
|
||||
<exclude>org.apache.maven:apache-maven</exclude>
|
||||
<exclude>org.apache.maven:maven-artifact</exclude>
|
||||
<exclude>org.apache.maven:maven-monitor</exclude>
|
||||
<exclude>org.apache.maven:maven-plugin-descriptor</exclude>
|
||||
<exclude>jdom:jdom</exclude>
|
||||
<exclude>org.apache.maven:apache-maven</exclude>
|
||||
<exclude>bouncycastle:bcprov-jdk15</exclude>
|
||||
<exclude>bouncycastle:bcpg-jdk15</exclude>
|
||||
<exclude>log4j:log4j</exclude>
|
||||
<exclude>org.sonatype.mercury:mercury-mp3-cli</exclude>
|
||||
<exclude>commons-logging:commons-logging-api</exclude>
|
||||
<exclude>org.slf4j:slf4j-api</exclude>
|
||||
<exclude>org.slf4j:slf4j-jdk14</exclude>
|
||||
<exclude>org.apache.maven.mercury:mercury-crypto-api</exclude>
|
||||
<exclude>org.apache.maven.mercury:mercury-crypto-basic</exclude-->
|
||||
</excludes>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
|
|
|
@ -21,17 +21,16 @@ package org.apache.maven.cli;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
import org.codehaus.plexus.util.Os;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
/**
|
||||
* Utility class used to report errors, statistics, application version info, etc.
|
||||
|
@ -50,24 +49,18 @@ public final class CLIReportingUtils
|
|||
|
||||
public static final String BUILD_VERSION_PROPERTY = "version";
|
||||
|
||||
public static void showVersion( PrintStream stdout )
|
||||
public static String showVersion()
|
||||
{
|
||||
String LS = System.getProperty("line.separator");
|
||||
Properties properties = getBuildProperties();
|
||||
stdout.println( createMavenVersionString( properties ) );
|
||||
String shortName = reduce( properties.getProperty( "distributionShortName" ) );
|
||||
|
||||
stdout.println( shortName + " home: " + System.getProperty( "maven.home", "<unknown maven home>" ) );
|
||||
|
||||
stdout.println( "Java version: " + System.getProperty( "java.version", "<unknown java version>" )
|
||||
+ ", vendor: " + System.getProperty( "java.vendor", "<unknown vendor>" ) );
|
||||
|
||||
stdout.println( "Java home: " + System.getProperty( "java.home", "<unknown java home>" ) );
|
||||
|
||||
stdout.println( "Default locale: " + Locale.getDefault() + ", platform encoding: "
|
||||
+ System.getProperty( "file.encoding", "<unknown encoding>" ) );
|
||||
|
||||
stdout.println( "OS name: \"" + Os.OS_NAME + "\", version: \"" + Os.OS_VERSION + "\", arch: \"" + Os.OS_ARCH
|
||||
+ "\", family: \"" + Os.OS_FAMILY + "\"" );
|
||||
StringBuffer version = new StringBuffer();
|
||||
version.append( createMavenVersionString( properties ) ).append( LS );
|
||||
version.append( reduce( properties.getProperty( "distributionShortName" ) + " home: " + System.getProperty( "maven.home", "<unknown maven home>" ) ) ).append( LS );
|
||||
version.append( "Java version: " + System.getProperty( "java.version", "<unknown java version>" ) + ", vendor: " + System.getProperty( "java.vendor", "<unknown vendor>" ) ).append( LS );
|
||||
version.append( "Java home: " + System.getProperty( "java.home", "<unknown java home>" ) ).append( LS );
|
||||
version.append( "Default locale: " + Locale.getDefault() + ", platform encoding: " + System.getProperty( "file.encoding", "<unknown encoding>" ) ).append( LS );
|
||||
version.append( "OS name: \"" + Os.OS_NAME + "\", version: \"" + Os.OS_VERSION + "\", arch: \"" + Os.OS_ARCH + "\", family: \"" + Os.OS_FAMILY + "\"" );
|
||||
return version.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,75 +98,6 @@ public final class CLIReportingUtils
|
|||
return ( s != null ? ( s.startsWith( "${" ) && s.endsWith( "}" ) ? null : s ) : null );
|
||||
}
|
||||
|
||||
|
||||
private static void stats( Date start, Logger logger )
|
||||
{
|
||||
Date finish = new Date();
|
||||
|
||||
long time = finish.getTime() - start.getTime();
|
||||
|
||||
logger.info( "Total time: " + formatTime( time ) );
|
||||
|
||||
logger.info( "Finished at: " + finish );
|
||||
|
||||
//noinspection CallToSystemGC
|
||||
System.gc();
|
||||
|
||||
Runtime r = Runtime.getRuntime();
|
||||
|
||||
logger.info( "Final Memory: " + ( r.totalMemory() - r.freeMemory() ) / MB + "M/" + r.totalMemory() / MB + "M" );
|
||||
}
|
||||
|
||||
private static String formatTime( long ms )
|
||||
{
|
||||
long secs = ms / MS_PER_SEC;
|
||||
|
||||
long min = secs / SEC_PER_MIN;
|
||||
|
||||
secs = secs % SEC_PER_MIN;
|
||||
|
||||
String msg = "";
|
||||
|
||||
if ( min > 1 )
|
||||
{
|
||||
msg = min + " minutes ";
|
||||
}
|
||||
else if ( min == 1 )
|
||||
{
|
||||
msg = "1 minute ";
|
||||
}
|
||||
|
||||
if ( secs > 1 )
|
||||
{
|
||||
msg += secs + " seconds";
|
||||
}
|
||||
else if ( secs == 1 )
|
||||
{
|
||||
msg += "1 second";
|
||||
}
|
||||
else if ( min == 0 )
|
||||
{
|
||||
msg += "< 1 second";
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
private static String getFormattedTime( long time )
|
||||
{
|
||||
String pattern = "s.SSS's'";
|
||||
if ( time / 60000L > 0 )
|
||||
{
|
||||
pattern = "m:s" + pattern;
|
||||
if ( time / 3600000L > 0 )
|
||||
{
|
||||
pattern = "H:m" + pattern;
|
||||
}
|
||||
}
|
||||
DateFormat fmt = new SimpleDateFormat( pattern );
|
||||
fmt.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
|
||||
return fmt.format( new Date( time ) );
|
||||
}
|
||||
|
||||
static Properties getBuildProperties()
|
||||
{
|
||||
Properties properties = new Properties();
|
||||
|
@ -201,11 +125,6 @@ public final class CLIReportingUtils
|
|||
|
||||
public static void showError( Logger logger, String message, Throwable e, boolean showStackTrace )
|
||||
{
|
||||
if ( logger == null )
|
||||
{
|
||||
logger = new PrintStreamLogger( System.out );
|
||||
}
|
||||
|
||||
if ( showStackTrace )
|
||||
{
|
||||
logger.error( message, e );
|
||||
|
|
|
@ -36,6 +36,13 @@ import org.apache.commons.cli.UnrecognizedOptionException;
|
|||
import org.apache.maven.BuildAbort;
|
||||
import org.apache.maven.InternalErrorException;
|
||||
import org.apache.maven.Maven;
|
||||
import org.apache.maven.cli.event.DefaultEventSpyContext;
|
||||
import org.apache.maven.cli.event.ExecutionEventLogger;
|
||||
import org.apache.maven.cli.logging.PrintStreamLogger;
|
||||
import org.apache.maven.cli.logging.Slf4jLoggerManager;
|
||||
import org.apache.maven.cli.transfer.BatchModeMavenTransferListener;
|
||||
import org.apache.maven.cli.transfer.ConsoleMavenTransferListener;
|
||||
import org.apache.maven.cli.transfer.QuietMavenTransferListener;
|
||||
import org.apache.maven.eventspy.internal.EventSpyDispatcher;
|
||||
import org.apache.maven.exception.DefaultExceptionHandler;
|
||||
import org.apache.maven.exception.ExceptionHandler;
|
||||
|
@ -64,9 +71,11 @@ 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.logging.LoggerManager;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.slf4j.ILoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.sonatype.aether.transfer.TransferListener;
|
||||
import org.sonatype.plexus.components.cipher.DefaultPlexusCipher;
|
||||
import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher;
|
||||
|
@ -106,7 +115,11 @@ public class MavenCli
|
|||
// Per-instance container supports fast embedded execution of core ITs
|
||||
private DefaultPlexusContainer container;
|
||||
|
||||
private Logger logger;
|
||||
private LoggerManager plexusLoggerManager;
|
||||
|
||||
private ILoggerFactory slf4jLoggerFactory;
|
||||
|
||||
private Logger slf4jLogger;
|
||||
|
||||
private EventSpyDispatcher eventSpyDispatcher;
|
||||
|
||||
|
@ -188,7 +201,6 @@ public class MavenCli
|
|||
try
|
||||
{
|
||||
initialize( cliRequest );
|
||||
// Need to process cli options first to get possible logging options
|
||||
cli( cliRequest );
|
||||
logging( cliRequest );
|
||||
version( cliRequest );
|
||||
|
@ -211,13 +223,13 @@ public class MavenCli
|
|||
}
|
||||
catch ( BuildAbort e )
|
||||
{
|
||||
CLIReportingUtils.showError( logger, "ABORTED", e, cliRequest.showErrors );
|
||||
CLIReportingUtils.showError( slf4jLogger, "ABORTED", e, cliRequest.showErrors );
|
||||
|
||||
return 2;
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
CLIReportingUtils.showError( logger, "Error executing Maven.", e, cliRequest.showErrors );
|
||||
CLIReportingUtils.showError( slf4jLogger, "Error executing Maven.", e, cliRequest.showErrors );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -227,10 +239,6 @@ public class MavenCli
|
|||
{
|
||||
localContainer.dispose();
|
||||
}
|
||||
if ( cliRequest.fileStream != null )
|
||||
{
|
||||
cliRequest.fileStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,54 +261,6 @@ public class MavenCli
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Logging needs to be handled in a standard way at the container level.
|
||||
//
|
||||
private void logging( CliRequest cliRequest )
|
||||
{
|
||||
cliRequest.debug = cliRequest.commandLine.hasOption( CLIManager.DEBUG );
|
||||
cliRequest.quiet = !cliRequest.debug && cliRequest.commandLine.hasOption( CLIManager.QUIET );
|
||||
cliRequest.showErrors = cliRequest.debug || cliRequest.commandLine.hasOption( CLIManager.ERRORS );
|
||||
|
||||
if ( cliRequest.debug )
|
||||
{
|
||||
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_DEBUG );
|
||||
}
|
||||
else if ( cliRequest.quiet )
|
||||
{
|
||||
// TODO: we need to do some more work here. Some plugins use sys out or log errors at info level.
|
||||
// Ideally, we could use Warn across the board
|
||||
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_ERROR );
|
||||
// TODO:Additionally, we can't change the mojo level because the component key includes the version and
|
||||
// it isn't known ahead of time. This seems worth changing.
|
||||
}
|
||||
else
|
||||
{
|
||||
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_INFO );
|
||||
}
|
||||
|
||||
if ( cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) )
|
||||
{
|
||||
File logFile = new File( cliRequest.commandLine.getOptionValue( CLIManager.LOG_FILE ) );
|
||||
logFile = resolveFile( logFile, cliRequest.workingDirectory );
|
||||
|
||||
try
|
||||
{
|
||||
cliRequest.fileStream = new PrintStream( logFile );
|
||||
|
||||
System.setOut( cliRequest.fileStream );
|
||||
System.setErr( cliRequest.fileStream );
|
||||
}
|
||||
catch ( FileNotFoundException e )
|
||||
{
|
||||
System.err.println( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Every bit of information taken from the CLI should be processed here.
|
||||
//
|
||||
private void cli( CliRequest cliRequest )
|
||||
throws Exception
|
||||
{
|
||||
|
@ -317,8 +277,6 @@ public class MavenCli
|
|||
throw e;
|
||||
}
|
||||
|
||||
// TODO: these should be moved out of here. Wrong place.
|
||||
//
|
||||
if ( cliRequest.commandLine.hasOption( CLIManager.HELP ) )
|
||||
{
|
||||
cliManager.displayHelp( System.out );
|
||||
|
@ -327,16 +285,53 @@ public class MavenCli
|
|||
|
||||
if ( cliRequest.commandLine.hasOption( CLIManager.VERSION ) )
|
||||
{
|
||||
CLIReportingUtils.showVersion( System.out );
|
||||
System.out.println(CLIReportingUtils.showVersion());
|
||||
throw new ExitException( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// All logging is handled by SFL4J
|
||||
//
|
||||
private void logging( CliRequest cliRequest )
|
||||
{
|
||||
cliRequest.debug = cliRequest.commandLine.hasOption( CLIManager.DEBUG );
|
||||
cliRequest.quiet = !cliRequest.debug && cliRequest.commandLine.hasOption( CLIManager.QUIET );
|
||||
cliRequest.showErrors = cliRequest.debug || cliRequest.commandLine.hasOption( CLIManager.ERRORS );
|
||||
|
||||
if ( cliRequest.debug )
|
||||
{
|
||||
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_DEBUG );
|
||||
System.setProperty( "org.slf4j.simpleLogger.defaultLogLevel", "debug" );
|
||||
}
|
||||
else if ( cliRequest.quiet )
|
||||
{
|
||||
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_ERROR );
|
||||
System.setProperty( "org.slf4j.simpleLogger.defaultLogLevel", "error" );
|
||||
}
|
||||
else
|
||||
{
|
||||
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_INFO );
|
||||
System.setProperty( "org.slf4j.simpleLogger.defaultLogLevel", "info" );
|
||||
}
|
||||
|
||||
if ( cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) )
|
||||
{
|
||||
File logFile = new File( cliRequest.commandLine.getOptionValue( CLIManager.LOG_FILE ) );
|
||||
logFile = resolveFile( logFile, cliRequest.workingDirectory );
|
||||
System.setProperty("org.slf4j.simpleLogger.logFile", logFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
plexusLoggerManager = new Slf4jLoggerManager();
|
||||
slf4jLoggerFactory = LoggerFactory.getILoggerFactory();
|
||||
slf4jLogger = slf4jLoggerFactory.getLogger(this.getClass().getName());
|
||||
}
|
||||
|
||||
private void version( CliRequest cliRequest )
|
||||
{
|
||||
if ( cliRequest.debug || cliRequest.commandLine.hasOption( CLIManager.SHOW_VERSION ) )
|
||||
{
|
||||
CLIReportingUtils.showVersion( System.out );
|
||||
System.out.print(CLIReportingUtils.showVersion());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -344,16 +339,16 @@ public class MavenCli
|
|||
{
|
||||
if ( cliRequest.showErrors )
|
||||
{
|
||||
logger.info( "Error stacktraces are turned on." );
|
||||
slf4jLogger.info( "Error stacktraces are turned on." );
|
||||
}
|
||||
|
||||
if ( MavenExecutionRequest.CHECKSUM_POLICY_WARN.equals( cliRequest.request.getGlobalChecksumPolicy() ) )
|
||||
{
|
||||
logger.info( "Disabling strict checksum verification on all artifact downloads." );
|
||||
slf4jLogger.info( "Disabling strict checksum verification on all artifact downloads." );
|
||||
}
|
||||
else if ( MavenExecutionRequest.CHECKSUM_POLICY_FAIL.equals( cliRequest.request.getGlobalChecksumPolicy() ) )
|
||||
{
|
||||
logger.info( "Enabling strict checksum verification on all artifact downloads." );
|
||||
slf4jLogger.info( "Enabling strict checksum verification on all artifact downloads." );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -374,10 +369,6 @@ public class MavenCli
|
|||
|
||||
if ( container == null )
|
||||
{
|
||||
logger = setupLogger( cliRequest );
|
||||
|
||||
final MavenLoggerManager loggerManager = new MavenLoggerManager( logger ) ;
|
||||
|
||||
ContainerConfiguration cc = new DefaultContainerConfiguration()
|
||||
.setClassWorld( cliRequest.classWorld )
|
||||
.setRealm( setupContainerRealm( cliRequest ) )
|
||||
|
@ -390,7 +381,7 @@ public class MavenCli
|
|||
|
||||
protected void configure()
|
||||
{
|
||||
bind( ILoggerFactory.class ).toInstance( new PlexusLoggerFactory( loggerManager ) );
|
||||
bind( ILoggerFactory.class ).toInstance( slf4jLoggerFactory );
|
||||
}
|
||||
|
||||
} );
|
||||
|
@ -398,7 +389,7 @@ public class MavenCli
|
|||
// NOTE: To avoid inconsistencies, we'll use the TCCL exclusively for lookups
|
||||
container.setLookupRealm( null );
|
||||
|
||||
container.setLoggerManager( loggerManager );
|
||||
container.setLoggerManager( plexusLoggerManager );
|
||||
|
||||
customizeContainer( container );
|
||||
|
||||
|
@ -424,7 +415,7 @@ public class MavenCli
|
|||
eventSpyDispatcher.init( eventSpyContext );
|
||||
|
||||
// refresh logger in case container got customized by spy
|
||||
logger = container.getLoggerManager().getLoggerForComponent( MavenCli.class.getName(), null );
|
||||
slf4jLogger = slf4jLoggerFactory.getLogger(this.getClass().getName());
|
||||
|
||||
maven = container.lookup( Maven.class );
|
||||
|
||||
|
@ -439,21 +430,6 @@ public class MavenCli
|
|||
return container;
|
||||
}
|
||||
|
||||
private PrintStreamLogger setupLogger( CliRequest cliRequest )
|
||||
{
|
||||
PrintStreamLogger logger = new PrintStreamLogger( new PrintStreamLogger.Provider()
|
||||
{
|
||||
public PrintStream getStream()
|
||||
{
|
||||
return System.out;
|
||||
}
|
||||
} );
|
||||
|
||||
logger.setThreshold( cliRequest.request.getLoggingLevel() );
|
||||
|
||||
return logger;
|
||||
}
|
||||
|
||||
private ClassRealm setupContainerRealm( CliRequest cliRequest )
|
||||
throws Exception
|
||||
{
|
||||
|
@ -479,13 +455,13 @@ public class MavenCli
|
|||
|
||||
ClassRealm extRealm = cliRequest.classWorld.newRealm( "maven.ext", null );
|
||||
|
||||
logger.debug( "Populating class realm " + extRealm.getId() );
|
||||
slf4jLogger.debug( "Populating class realm " + extRealm.getId() );
|
||||
|
||||
for ( String jar : jars )
|
||||
{
|
||||
File file = resolveFile( new File( jar ), cliRequest.workingDirectory );
|
||||
|
||||
logger.debug( " Included " + file );
|
||||
slf4jLogger.debug( " Included " + file );
|
||||
|
||||
extRealm.addURL( file.toURI().toURL() );
|
||||
}
|
||||
|
@ -499,10 +475,6 @@ public class MavenCli
|
|||
return containerRealm;
|
||||
}
|
||||
|
||||
protected void customizeContainer( PlexusContainer container )
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// This should probably be a separate tool and not be baked into Maven.
|
||||
//
|
||||
|
@ -583,39 +555,39 @@ public class MavenCli
|
|||
}
|
||||
}
|
||||
|
||||
logger.error( "" );
|
||||
slf4jLogger.error( "" );
|
||||
|
||||
if ( !cliRequest.showErrors )
|
||||
{
|
||||
logger.error( "To see the full stack trace of the errors, re-run Maven with the -e switch." );
|
||||
slf4jLogger.error( "To see the full stack trace of the errors, re-run Maven with the -e switch." );
|
||||
}
|
||||
if ( !logger.isDebugEnabled() )
|
||||
if ( !slf4jLogger.isDebugEnabled() )
|
||||
{
|
||||
logger.error( "Re-run Maven using the -X switch to enable full debug logging." );
|
||||
slf4jLogger.error( "Re-run Maven using the -X switch to enable full debug logging." );
|
||||
}
|
||||
|
||||
if ( !references.isEmpty() )
|
||||
{
|
||||
logger.error( "" );
|
||||
logger.error( "For more information about the errors and possible solutions"
|
||||
slf4jLogger.error( "" );
|
||||
slf4jLogger.error( "For more information about the errors and possible solutions"
|
||||
+ ", please read the following articles:" );
|
||||
|
||||
for ( Map.Entry<String, String> entry : references.entrySet() )
|
||||
{
|
||||
logger.error( entry.getValue() + " " + entry.getKey() );
|
||||
slf4jLogger.error( entry.getValue() + " " + entry.getKey() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( project != null && !project.equals( result.getTopologicallySortedProjects().get( 0 ) ) )
|
||||
{
|
||||
logger.error( "" );
|
||||
logger.error( "After correcting the problems, you can resume the build with the command" );
|
||||
logger.error( " mvn <goals> -rf :" + project.getArtifactId() );
|
||||
slf4jLogger.error( "" );
|
||||
slf4jLogger.error( "After correcting the problems, you can resume the build with the command" );
|
||||
slf4jLogger.error( " mvn <goals> -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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
* <p/>
|
||||
* Sample configuration:
|
||||
* <pre>
|
||||
* <logging>
|
||||
* <implementation>org.codehaus.plexus.logging.ConsoleLoggerManager</implementation>
|
||||
* <logger>
|
||||
* <threshold>DEBUG</threshold>
|
||||
* </logger>
|
||||
* </logging>
|
||||
* </pre>
|
||||
*
|
||||
* @author Jason van Zyl
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
*/
|
||||
public class MavenLoggerManager
|
||||
extends AbstractLoggerManager
|
||||
implements LoggerManager, Initializable
|
||||
{
|
||||
/**
|
||||
* Message of this level or higher will be logged.
|
||||
* <p/>
|
||||
* 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 )
|
||||
{
|
||||
}
|
||||
}
|
|
@ -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 );
|
||||
}
|
||||
|
||||
}
|
|
@ -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 ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.cli;
|
||||
package org.apache.maven.cli.event;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
@ -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.
|
|
@ -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();
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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 + ")" );
|
||||
}
|
||||
}
|
|
@ -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 );
|
||||
}
|
|
@ -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() );
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.cli;
|
||||
package org.apache.maven.cli.transfer;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
13
pom.xml
13
pom.xml
|
@ -211,10 +211,21 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-nop</artifactId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${slf4jVersion}</version>
|
||||
<scope>runtime</scope>
|
||||
<<<<<<< HEAD
|
||||
</dependency>
|
||||
=======
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${log4jVersion}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
>>>>>>> 4595e08... o Use SLF4J for logging
|
||||
<!-- Wagon -->
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
|
|
Loading…
Reference in New Issue