You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by st...@apache.org on 2012/12/12 12:03:19 UTC
git commit: oops forgot to commit these
Updated Branches:
refs/heads/logging/slf4j-log4j 262d644d4 -> 66ac27734
oops forgot to commit these
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/66ac2773
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/66ac2773
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/66ac2773
Branch: refs/heads/logging/slf4j-log4j
Commit: 66ac27734d1564572ba249b76fd8998f99571186
Parents: 262d644
Author: Stephen Connolly <st...@gmail.com>
Authored: Wed Dec 12 11:02:56 2012 +0000
Committer: Stephen Connolly <st...@gmail.com>
Committed: Wed Dec 12 11:02:56 2012 +0000
----------------------------------------------------------------------
apache-maven/pom.xml | 8 +-
maven-embedder/pom.xml | 8 +
.../main/java/org/apache/maven/cli/MavenCli.java | 127 ++++++++-------
pom.xml | 11 +-
4 files changed, 91 insertions(+), 63 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/66ac2773/apache-maven/pom.xml
----------------------------------------------------------------------
diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml
index ce547e7..30e7018 100644
--- a/apache-maven/pom.xml
+++ b/apache-maven/pom.xml
@@ -85,7 +85,13 @@
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.7.2</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.17</version>
</dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/maven/blob/66ac2773/maven-embedder/pom.xml
----------------------------------------------------------------------
diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml
index 587398f..8a8baef 100644
--- a/maven-embedder/pom.xml
+++ b/maven-embedder/pom.xml
@@ -74,6 +74,14 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
<!-- CLI -->
<dependency>
<groupId>commons-cli</groupId>
http://git-wip-us.apache.org/repos/asf/maven/blob/66ac2773/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
index e744e65..90b69eb 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
@@ -34,6 +34,7 @@ import java.util.StringTokenizer;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.UnrecognizedOptionException;
+import org.apache.log4j.Level;
import org.apache.maven.BuildAbort;
import org.apache.maven.InternalErrorException;
import org.apache.maven.Maven;
@@ -77,6 +78,7 @@ import org.codehaus.plexus.util.StringUtils;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.impl.Log4jLoggerAdapter;
import org.sonatype.aether.transfer.TransferListener;
import org.sonatype.plexus.components.cipher.DefaultPlexusCipher;
import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher;
@@ -116,9 +118,9 @@ public class MavenCli
private LoggerManager plexusLoggerManager;
private ILoggerFactory slf4jLoggerFactory;
-
+
private Logger slf4jLogger;
-
+
private EventSpyDispatcher eventSpyDispatcher;
private ModelProcessor modelProcessor;
@@ -263,7 +265,8 @@ public class MavenCli
throws Exception
{
//
- // Parsing errors can happen during the processing of the arguments and we prefer not having to check if the logger is null
+ // Parsing errors can happen during the processing of the arguments and we prefer not having to check if the
+ // logger is null
// and construct this so we can use an SLF4J logger everywhere.
//
slf4jLogger = new Slf4jStdoutLogger();
@@ -292,7 +295,7 @@ public class MavenCli
System.out.println( CLIReportingUtils.showVersion() );
throw new ExitException( 0 );
}
- }
+ }
//
// All logging is handled by SFL4J
@@ -306,24 +309,23 @@ public class MavenCli
if ( cliRequest.debug )
{
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_DEBUG );
- System.setProperty( "org.slf4j.simpleLogger.defaultLogLevel", "debug" );
+ setRootLoggerLevel( Level.DEBUG );
}
else if ( cliRequest.quiet )
{
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_ERROR );
- System.setProperty( "org.slf4j.simpleLogger.defaultLogLevel", "error" );
+ setRootLoggerLevel( Level.ERROR );
}
else
{
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_INFO );
- System.setProperty( "org.slf4j.simpleLogger.defaultLogLevel", "info" );
+ setRootLoggerLevel( Level.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() );
try
{
PrintStream ps = new PrintStream( new FileOutputStream( logFile ) );
@@ -343,6 +345,11 @@ public class MavenCli
slf4jLogger = slf4jLoggerFactory.getLogger( this.getClass().getName() );
}
+ public void setRootLoggerLevel( Level level )
+ {
+ org.apache.log4j.Logger.getRootLogger().setLevel( level );
+ }
+
private void version( CliRequest cliRequest )
{
if ( cliRequest.debug || cliRequest.commandLine.hasOption( CLIManager.SHOW_VERSION ) )
@@ -383,29 +390,27 @@ public class MavenCli
DefaultPlexusContainer container = null;
- ContainerConfiguration cc = new DefaultContainerConfiguration()
- .setClassWorld( cliRequest.classWorld )
- .setRealm( setupContainerRealm( cliRequest ) )
- .setClassPathScanning( PlexusConstants.SCANNING_INDEX )
- .setAutoWiring( true )
- .setName( "maven" );
+ ContainerConfiguration cc =
+ new DefaultContainerConfiguration().setClassWorld( cliRequest.classWorld ).setRealm(
+ setupContainerRealm( cliRequest ) ).setClassPathScanning(
+ PlexusConstants.SCANNING_INDEX ).setAutoWiring( true ).setName( "maven" );
- container = new DefaultPlexusContainer( cc, new AbstractModule()
- {
+ container = new DefaultPlexusContainer( cc, new AbstractModule()
+ {
- protected void configure()
- {
- bind( ILoggerFactory.class ).toInstance( slf4jLoggerFactory );
- }
+ protected void configure()
+ {
+ bind( ILoggerFactory.class ).toInstance( slf4jLoggerFactory );
+ }
- } );
+ } );
- // NOTE: To avoid inconsistencies, we'll use the TCCL exclusively for lookups
- container.setLookupRealm( null );
+ // NOTE: To avoid inconsistencies, we'll use the TCCL exclusively for lookups
+ container.setLookupRealm( null );
- container.setLoggerManager( plexusLoggerManager );
+ container.setLoggerManager( plexusLoggerManager );
- customizeContainer( container );
+ customizeContainer( container );
container.getLoggerManager().setThresholds( cliRequest.request.getLoggingLevel() );
@@ -578,7 +583,7 @@ public class MavenCli
{
slf4jLogger.error( "" );
slf4jLogger.error( "For more information about the errors and possible solutions"
- + ", please read the following articles:" );
+ + ", please read the following articles:" );
for ( Map.Entry<String, String> entry : references.entrySet() )
{
@@ -610,8 +615,7 @@ public class MavenCli
}
}
- private void logSummary( ExceptionSummary summary, Map<String, String> references, String indent,
- boolean showErrors )
+ private void logSummary( ExceptionSummary summary, Map<String, String> references, String indent, boolean showErrors )
{
String referenceKey = "";
@@ -675,8 +679,7 @@ public class MavenCli
if ( !userSettingsFile.isFile() )
{
- throw new FileNotFoundException( "The specified user settings file does not exist: "
- + userSettingsFile );
+ throw new FileNotFoundException( "The specified user settings file does not exist: " + userSettingsFile );
}
}
else
@@ -880,7 +883,7 @@ public class MavenCli
if ( quiet )
{
transferListener = new QuietMavenTransferListener();
- }
+ }
else if ( request.isInteractiveMode() && !cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) )
{
//
@@ -914,20 +917,22 @@ public class MavenCli
userToolchainsFile = MavenCli.DEFAULT_USER_TOOLCHAINS_FILE;
}
- request.setBaseDirectory( baseDirectory ).setGoals( goals )
- .setSystemProperties( cliRequest.systemProperties )
- .setUserProperties( cliRequest.userProperties )
- .setReactorFailureBehavior( reactorFailureBehaviour ) // default: fail fast
- .setRecursive( recursive ) // default: true
- .setShowErrors( showErrors ) // default: false
- .addActiveProfiles( activeProfiles ) // optional
- .addInactiveProfiles( inactiveProfiles ) // optional
- .setExecutionListener( executionListener )
- .setTransferListener( transferListener ) // default: batch mode which goes along with interactive
- .setUpdateSnapshots( updateSnapshots ) // default: false
- .setNoSnapshotUpdates( noSnapshotUpdates ) // default: false
- .setGlobalChecksumPolicy( globalChecksumPolicy ) // default: warn
- .setUserToolchainsFile( userToolchainsFile );
+ request.setBaseDirectory( baseDirectory ).setGoals( goals ).setSystemProperties(
+ cliRequest.systemProperties ).setUserProperties( cliRequest.userProperties ).setReactorFailureBehavior(
+ reactorFailureBehaviour ) // default:
+ // fail
+ // fast
+ .setRecursive( recursive ) // default: true
+ .setShowErrors( showErrors ) // default: false
+ .addActiveProfiles( activeProfiles ) // optional
+ .addInactiveProfiles( inactiveProfiles ) // optional
+ .setExecutionListener( executionListener ).setTransferListener( transferListener ) // default: batch mode which
+ // goes along with
+ // interactive
+ .setUpdateSnapshots( updateSnapshots ) // default: false
+ .setNoSnapshotUpdates( noSnapshotUpdates ) // default: false
+ .setGlobalChecksumPolicy( globalChecksumPolicy ) // default: warn
+ .setUserToolchainsFile( userToolchainsFile );
if ( alternatePomFile != null )
{
@@ -971,18 +976,17 @@ public class MavenCli
request.setSelectedProjects( projects );
}
- if ( commandLine.hasOption( CLIManager.ALSO_MAKE )
- && !commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) )
+ if ( commandLine.hasOption( CLIManager.ALSO_MAKE ) && !commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) )
{
request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_UPSTREAM );
}
else if ( !commandLine.hasOption( CLIManager.ALSO_MAKE )
- && commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) )
+ && commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) )
{
request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM );
}
else if ( commandLine.hasOption( CLIManager.ALSO_MAKE )
- && commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) )
+ && commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) )
{
request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_BOTH );
}
@@ -999,10 +1003,13 @@ public class MavenCli
request.setLocalRepositoryPath( localRepoProperty );
}
- final String threadConfiguration = commandLine.hasOption( CLIManager.THREADS )
- ? commandLine.getOptionValue( CLIManager.THREADS )
- : request.getSystemProperties().getProperty(
- MavenCli.THREADS_DEPRECATED ); // TODO: Remove this setting. Note that the int-tests use it
+ final String threadConfiguration =
+ commandLine.hasOption( CLIManager.THREADS ) ? commandLine.getOptionValue( CLIManager.THREADS )
+ : request.getSystemProperties().getProperty( MavenCli.THREADS_DEPRECATED ); // TODO: Remove
+ // this setting.
+ // Note that the
+ // int-tests use
+ // it
if ( threadConfiguration != null )
{
@@ -1069,7 +1076,7 @@ public class MavenCli
}
systemProperties.putAll( System.getProperties() );
-
+
// ----------------------------------------------------------------------
// Properties containing info about the currently running version of Maven
// These override any corresponding properties set on the command line
@@ -1148,21 +1155,21 @@ public class MavenCli
}
}
-
+
//
// Customizations available via the CLI
//
-
- protected TransferListener getConsoleTransferListener()
+
+ protected TransferListener getConsoleTransferListener()
{
return new ConsoleMavenTransferListener( System.out );
}
-
+
protected TransferListener getBatchTransferListener()
{
return new Slf4jMavenTransferListener();
}
-
+
protected void customizeContainer( PlexusContainer container )
{
}
@@ -1171,5 +1178,5 @@ public class MavenCli
throws ComponentLookupException
{
return container.lookup( ModelProcessor.class );
- }
+ }
}
http://git-wip-us.apache.org/repos/asf/maven/blob/66ac2773/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d673939..63a1f58 100644
--- a/pom.xml
+++ b/pom.xml
@@ -57,6 +57,7 @@
<jxpathVersion>1.3</jxpathVersion>
<aetherVersion>1.13.1</aetherVersion>
<slf4jVersion>1.7.2</slf4jVersion>
+ <log4jVersion>1.2.17</log4jVersion>
<maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
<!-- Control the name of the distribution and information output by mvn -->
<distributionId>apache-maven</distributionId>
@@ -212,9 +213,15 @@
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
+ <artifactId>slf4j-log4j12</artifactId>
<version>${slf4jVersion}</version>
- <scope>runtime</scope>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${log4jVersion}</version>
+ <scope>compile</scope>
</dependency>
<!-- Wagon -->
<dependency>