You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2012/12/09 03:51:51 UTC
[1/30] git commit: o Maven with Logback now passes all the ITs,
needed to correct the warning string and set the appropriate log
levels
Updated Branches:
refs/heads/slf4j-logback 10ff74128 -> ed4b5bf98
o Maven with Logback now passes all the ITs, needed to correct the warning string and set the appropriate log levels
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/ed4b5bf9
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/ed4b5bf9
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/ed4b5bf9
Branch: refs/heads/slf4j-logback
Commit: ed4b5bf98f520d0c9775e5bb6fb7075ac1db5fa0
Parents: c21d294
Author: Jason van Zyl <jv...@apache.org>
Authored: Sat Dec 8 21:51:02 2012 -0500
Committer: Jason van Zyl <jv...@apache.org>
Committed: Sat Dec 8 21:51:02 2012 -0500
----------------------------------------------------------------------
apache-maven/src/conf/logging/logback.xml | 4 +-
maven-embedder/pom.xml | 7 +-
.../main/java/org/apache/maven/cli/MavenCli.java | 132 ++++++++-------
pom.xml | 4 +-
4 files changed, 82 insertions(+), 65 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/ed4b5bf9/apache-maven/src/conf/logging/logback.xml
----------------------------------------------------------------------
diff --git a/apache-maven/src/conf/logging/logback.xml b/apache-maven/src/conf/logging/logback.xml
index 6294e95..37567f9 100644
--- a/apache-maven/src/conf/logging/logback.xml
+++ b/apache-maven/src/conf/logging/logback.xml
@@ -3,9 +3,9 @@
<withJansi>true</withJansi>
<encoder>
<!--
- <pattern>[%level] %msg%n</pattern>
- -->
<pattern>%highlight([%level]) %black(%msg) %n</pattern>
+ -->
+ <pattern>[%replace(%level){'WARN','WARNING'}] %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
http://git-wip-us.apache.org/repos/asf/maven/blob/ed4b5bf9/maven-embedder/pom.xml
----------------------------------------------------------------------
diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml
index 587398f..452434f 100644
--- a/maven-embedder/pom.xml
+++ b/maven-embedder/pom.xml
@@ -10,7 +10,8 @@
governing permissions and limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -74,6 +75,10 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </dependency>
<!-- CLI -->
<dependency>
<groupId>commons-cli</groupId>
http://git-wip-us.apache.org/repos/asf/maven/blob/ed4b5bf9/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..e0b0d42 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
@@ -84,6 +84,8 @@ import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher;
import org.sonatype.plexus.components.sec.dispatcher.SecUtil;
import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity;
+import ch.qos.logback.classic.Level;
+
import com.google.inject.AbstractModule;
// TODO: push all common bits back to plexus cli and prepare for transition to Guice. We don't need 50 ways to make CLIs
@@ -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 )
+ {
+ ( (ch.qos.logback.classic.Logger) LoggerFactory.getLogger( Logger.ROOT_LOGGER_NAME ) ).setLevel( level );
+ }
+
private void version( CliRequest cliRequest )
{
if ( cliRequest.debug || cliRequest.commandLine.hasOption( CLIManager.SHOW_VERSION ) )
@@ -383,29 +390,25 @@ 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 +581,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 +613,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 +677,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 +881,7 @@ public class MavenCli
if ( quiet )
{
transferListener = new QuietMavenTransferListener();
- }
+ }
else if ( request.isInteractiveMode() && !cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) )
{
//
@@ -914,20 +915,20 @@ 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 +972,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 +999,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 +1072,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
@@ -1118,14 +1121,23 @@ public class MavenCli
static class CliRequest
{
String[] args;
+
CommandLine commandLine;
+
ClassWorld classWorld;
+
String workingDirectory;
+
boolean debug;
+
boolean quiet;
+
boolean showErrors = true;
+
Properties userProperties = new Properties();
+
Properties systemProperties = new Properties();
+
MavenExecutionRequest request;
CliRequest( String[] args, ClassWorld classWorld )
@@ -1148,21 +1160,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 +1183,5 @@ public class MavenCli
throws ComponentLookupException
{
return container.lookup( ModelProcessor.class );
- }
+ }
}
http://git-wip-us.apache.org/repos/asf/maven/blob/ed4b5bf9/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 24238f8..73b4852 100644
--- a/pom.xml
+++ b/pom.xml
@@ -216,13 +216,13 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logbackVersion}</version>
- <scope>runtime</scope>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logbackVersion}</version>
- <scope>runtime</scope>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>org.fusesource.jansi</groupId>