You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2012/12/01 21:28:07 UTC
[6/6] git commit: add a dynamic way to choose logging framework impl
in MAVEN_OPTS -Dmaven.logger.impl=log4j2 or slf4j-simple (default log4j2)
add a dynamic way to choose logging framework impl
in MAVEN_OPTS -Dmaven.logger.impl=log4j2 or slf4j-simple (default log4j2)
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/65cd8e6b
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/65cd8e6b
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/65cd8e6b
Branch: refs/heads/dynamic-logging-impl
Commit: 65cd8e6bdf94a7dd62ef6005a0fad9ae55621403
Parents: af70de4
Author: olivier lamy <ol...@apache.org>
Authored: Sat Dec 1 16:11:30 2012 +0100
Committer: olivier lamy <ol...@apache.org>
Committed: Sat Dec 1 16:11:30 2012 +0100
----------------------------------------------------------------------
apache-maven/pom.xml | 16 ++++
apache-maven/src/bin/m2.conf | 8 ++-
apache-maven/src/conf/logging/log4j2.xml | 61 +++++++++++++++
apache-maven/src/main/assembly/bin.xml | 22 +++++
.../org/apache/maven/cli/startup/MavenStartup.java | 59 ++++++++++++++
5 files changed, 165 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/65cd8e6b/apache-maven/pom.xml
----------------------------------------------------------------------
diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml
index ce547e7..b17eb35 100644
--- a/apache-maven/pom.xml
+++ b/apache-maven/pom.xml
@@ -87,6 +87,22 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-ext</artifactId>
+ <version>1.7.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j.adapters</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <version>2.0-beta3</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.fusesource.jansi</groupId>
+ <artifactId>jansi</artifactId>
+ <version>1.9</version>
+ </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/maven/blob/65cd8e6b/apache-maven/src/bin/m2.conf
----------------------------------------------------------------------
diff --git a/apache-maven/src/bin/m2.conf b/apache-maven/src/bin/m2.conf
index 2991e0b..7805d0a 100644
--- a/apache-maven/src/bin/m2.conf
+++ b/apache-maven/src/bin/m2.conf
@@ -1,4 +1,4 @@
-main is org.apache.maven.cli.MavenCli from plexus.core
+main is org.apache.maven.cli.startup.MavenStartup from plexus.core
set maven.home default ${user.home}/m2
@@ -6,3 +6,9 @@ set maven.home default ${user.home}/m2
optionally ${maven.home}/lib/ext/*.jar
load ${maven.home}/lib/*.jar
load ${maven.home}/conf/logging
+
+[slf4j-simple]
+load ${maven.home}/slf4j-simple/*.jar
+
+[log4j2]
+load ${maven.home}/log4j2/*.jar
http://git-wip-us.apache.org/repos/asf/maven/blob/65cd8e6b/apache-maven/src/conf/logging/log4j2.xml
----------------------------------------------------------------------
diff --git a/apache-maven/src/conf/logging/log4j2.xml b/apache-maven/src/conf/logging/log4j2.xml
new file mode 100644
index 0000000..367122f
--- /dev/null
+++ b/apache-maven/src/conf/logging/log4j2.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ 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.
+ -->
+
+
+<configuration> <!--status="debug"-->
+
+ <properties>
+ <property name="maven.logging.root.level">INFO</property>
+ </properties>
+
+ <appenders>
+ <Console name="console" target="SYSTEM_OUT">
+ <!--PatternLayout pattern="%highlight[%p{WARN=WARNING}] %msg%n{FATAL=white, ERROR=red, WARN=blue, INFO=black, DEBUG=green, TRACE=blue}"/-->
+ <PatternLayout pattern="%highlight{%c{} [%p] %msg%n%throwable}{FATAL=white, ERROR=red, WARN=blue, INFO=black, DEBUG=green, TRACE=blue}" />
+ </Console>
+ <Console name="console-transfer" target="SYSTEM_OUT">
+ <PatternLayout pattern="[%p{WARN=WARNING}] %msg"/>
+ </Console>
+ <Console name="debug-console" target="SYSTEM_OUT">
+ <!--PatternLayout pattern="%highlight[%p{WARN=WARNING}] %msg%n{FATAL=white, ERROR=red, WARN=blue, INFO=black, DEBUG=green, TRACE=blue}"/-->
+ <PatternLayout pattern="%highlight{%c{} [%p] %msg%n%throwable}{FATAL=white, ERROR=red, WARN=blue, INFO=black, DEBUG=green, TRACE=blue}" />
+ </Console>
+ </appenders>
+ <loggers>
+
+ <logger name="Sisu" level="info"/>
+
+ <logger name="maven.maven-clean-plugin" level="debug" additivity="false">
+ <appender-ref ref="debug-console"/>
+ </logger>
+
+ <logger name="maven.maven-compiler-plugin" level="debug" additivity="false">
+ <appender-ref ref="debug-console"/>
+ </logger>
+
+ <logger name="consoleTransfer" level="info" additivity="false">
+ <appender-ref ref="console-transfer"/>
+ </logger>
+
+ <root level="${sys:maven.logging.root.level}">
+ <appender-ref ref="console"/>
+ </root>
+ </loggers>
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven/blob/65cd8e6b/apache-maven/src/main/assembly/bin.xml
----------------------------------------------------------------------
diff --git a/apache-maven/src/main/assembly/bin.xml b/apache-maven/src/main/assembly/bin.xml
index 4603a82..6b6a2c2 100644
--- a/apache-maven/src/main/assembly/bin.xml
+++ b/apache-maven/src/main/assembly/bin.xml
@@ -38,6 +38,28 @@ under the License.
<exclude>org.codehaus.plexus:plexus-classworlds</exclude>
<exclude>junit:junit</exclude>
<exclude>commons-logging:commons-logging-api</exclude>
+ <exclude>org.apache.logging.log4j.adapters:log4j-slf4j-impl</exclude>
+ <exclude>org.apache.logging.log4j:*</exclude>
+ <exclude>org.slf4j:slf4j-simple</exclude>
+ </excludes>
+ </dependencySet>
+ <dependencySet>
+ <useProjectArtifact>false</useProjectArtifact>
+ <outputDirectory>slf4j-simple</outputDirectory>
+ <includes>
+ <include>org.slf4j:slf4j-simple</include>
+ </includes>
+ </dependencySet>
+ <dependencySet>
+ <useProjectArtifact>false</useProjectArtifact>
+ <outputDirectory>log4j2</outputDirectory>
+ <includes>
+ <include>org.apache.logging.log4j.adapters:log4j-slf4j-impl</include>
+ <include>org.apache.logging.log4j:*</include>
+ <include></include>
+ </includes>
+ <excludes>
+ <exclude>org.slf4j:slf4j-simple</exclude>
</excludes>
</dependencySet>
</dependencySets>
http://git-wip-us.apache.org/repos/asf/maven/blob/65cd8e6b/maven-embedder/src/main/java/org/apache/maven/cli/startup/MavenStartup.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/startup/MavenStartup.java b/maven-embedder/src/main/java/org/apache/maven/cli/startup/MavenStartup.java
new file mode 100644
index 0000000..f449bd1
--- /dev/null
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/startup/MavenStartup.java
@@ -0,0 +1,59 @@
+package org.apache.maven.cli.startup;
+
+/*
+ * 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.classworlds.ClassWorld;
+import org.codehaus.plexus.classworlds.realm.ClassRealm;
+import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
+
+import java.net.URL;
+
+/**
+ * @author Olivier Lamy
+ */
+public class MavenStartup
+{
+ public static int main( String[] args )
+ {
+ //int result = doMain( args, null );
+
+ return 1;
+ }
+
+ public static int main( String[] args, ClassWorld classWorld )
+ {
+ String loggerImplRealmId = System.getProperty( "maven.logger.impl", "log4j2" );
+
+ try
+ {
+ ClassRealm classRealm = classWorld.getRealm( loggerImplRealmId );
+ for (URL url : classRealm.getURLs())
+ {
+ classWorld.getRealm( "plexus.core" ).addURL( url );
+ }
+ return org.apache.maven.cli.MavenCli.doMain( args, classWorld );
+ }
+ catch ( NoSuchRealmException e )
+ {
+ e.printStackTrace();
+ }
+ return 1;
+ }
+}