Return-Path: X-Original-To: apmail-incubator-rat-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-rat-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E2E9396E0 for ; Wed, 28 Dec 2011 10:30:46 +0000 (UTC) Received: (qmail 38052 invoked by uid 500); 28 Dec 2011 10:30:46 -0000 Delivered-To: apmail-incubator-rat-commits-archive@incubator.apache.org Received: (qmail 38026 invoked by uid 500); 28 Dec 2011 10:30:46 -0000 Mailing-List: contact rat-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: rat-dev@incubator.apache.org Delivered-To: mailing list rat-commits@incubator.apache.org Received: (qmail 38019 invoked by uid 99); 28 Dec 2011 10:30:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Dec 2011 10:30:46 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Dec 2011 10:30:41 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5283B23888E7; Wed, 28 Dec 2011 10:30:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1225155 - in /incubator/rat/whisker/trunk: ./ apache-whisker-cli/ apache-whisker-cli/src/main/java/org/apache/rat/whisker/cli/ apache-whisker-plugin4maven/ apache-whisker-plugin4maven/src/main/java/org/apache/rat/whisker/plugin/maven/ apac... Date: Wed, 28 Dec 2011 10:30:18 -0000 To: rat-commits@incubator.apache.org From: rdonkin@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111228103019.5283B23888E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rdonkin Date: Wed Dec 28 10:30:18 2011 New Revision: 1225155 URL: http://svn.apache.org/viewvc?rev=1225155&view=rev Log: Switch to CLI API to bridge logging architectures. Added: incubator/rat/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/rat/whisker/cli/SystemLog.java (with props) incubator/rat/whisker/trunk/apache-whisker-plugin4maven/src/main/java/org/apache/rat/whisker/plugin/maven/MojoToJCLLog.java (with props) Modified: incubator/rat/whisker/trunk/apache-whisker-cli/pom.xml incubator/rat/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/rat/whisker/cli/Main.java incubator/rat/whisker/trunk/apache-whisker-plugin4maven/pom.xml incubator/rat/whisker/trunk/apache-whisker-plugin4maven/src/main/java/org/apache/rat/whisker/plugin/maven/GenerateMojo.java incubator/rat/whisker/trunk/apache-whisker-velocity/pom.xml incubator/rat/whisker/trunk/apache-whisker-velocity/src/main/java/org/apache/rat/whisker/out/velocity/VelocityEngine.java incubator/rat/whisker/trunk/apache-whisker-velocity/src/main/java/org/apache/rat/whisker/out/velocity/VelocityReports.java incubator/rat/whisker/trunk/pom.xml Modified: incubator/rat/whisker/trunk/apache-whisker-cli/pom.xml URL: http://svn.apache.org/viewvc/incubator/rat/whisker/trunk/apache-whisker-cli/pom.xml?rev=1225155&r1=1225154&r2=1225155&view=diff ============================================================================== --- incubator/rat/whisker/trunk/apache-whisker-cli/pom.xml (original) +++ incubator/rat/whisker/trunk/apache-whisker-cli/pom.xml Wed Dec 28 10:30:18 2011 @@ -36,6 +36,11 @@ + commons-logging + commons-logging-api + + + commons-cli commons-cli Modified: incubator/rat/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/rat/whisker/cli/Main.java URL: http://svn.apache.org/viewvc/incubator/rat/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/rat/whisker/cli/Main.java?rev=1225155&r1=1225154&r2=1225155&view=diff ============================================================================== --- incubator/rat/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/rat/whisker/cli/Main.java (original) +++ incubator/rat/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/rat/whisker/cli/Main.java Wed Dec 28 10:30:18 2011 @@ -85,7 +85,7 @@ public class Main { * @throws MissingOptionException */ private Whisker configure(final CommandLine commandLine) throws MissingOptionException { - whisker.setEngine(new VelocityEngine()); + whisker.setEngine(new VelocityEngine(new SystemLog())); whisker.setSource(CommandLineOption.SOURCE.getOptionValue(commandLine)); whisker.setLicenseDescriptor( new StreamableResourceFactory().streamFromClassPathResource( Added: incubator/rat/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/rat/whisker/cli/SystemLog.java URL: http://svn.apache.org/viewvc/incubator/rat/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/rat/whisker/cli/SystemLog.java?rev=1225155&view=auto ============================================================================== --- incubator/rat/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/rat/whisker/cli/SystemLog.java (added) +++ incubator/rat/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/rat/whisker/cli/SystemLog.java Wed Dec 28 10:30:18 2011 @@ -0,0 +1,177 @@ +/** + * 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. + */ +package org.apache.rat.whisker.cli; + +import org.apache.commons.logging.Log; + +/** + * Logs to system err + */ +public class SystemLog implements Log { + + /** + * @see org.apache.commons.logging.Log#debug(java.lang.Object) + */ + @Override + public void debug(Object message) {} + + /** + * @see org.apache.commons.logging.Log#debug(java.lang.Object, java.lang.Throwable) + */ + @Override + public void debug(Object message, Throwable t) {} + + /** + * @see org.apache.commons.logging.Log#error(java.lang.Object) + */ + @Override + public void error(Object message) { + err(message); + } + + /** + * @param message + */ + private void err(Object message) { + System.err.println(message); + } + + /** + * @see org.apache.commons.logging.Log#error(java.lang.Object, java.lang.Throwable) + */ + @Override + public void error(Object message, Throwable t) { + err(message, t); + } + + /** + * @param message + * @param t + */ + private void err(Object message, Throwable t) { + err(message); + t.printStackTrace(); + } + + /** + * @see org.apache.commons.logging.Log#fatal(java.lang.Object) + */ + @Override + public void fatal(Object message) { + err(message); + } + + /** + * @see org.apache.commons.logging.Log#fatal(java.lang.Object, java.lang.Throwable) + */ + @Override + public void fatal(Object message, Throwable t) { + err(message, t); + } + + /** + * @see org.apache.commons.logging.Log#info(java.lang.Object) + */ + @Override + public void info(Object message) { + } + + /** + * @see org.apache.commons.logging.Log#info(java.lang.Object, java.lang.Throwable) + */ + @Override + public void info(Object message, Throwable t) { + } + + /** + * @see org.apache.commons.logging.Log#isDebugEnabled() + */ + @Override + public boolean isDebugEnabled() { + return false; + } + + /** + * @see org.apache.commons.logging.Log#isErrorEnabled() + */ + @Override + public boolean isErrorEnabled() { + return true; + } + + /** + * @see org.apache.commons.logging.Log#isFatalEnabled() + */ + @Override + public boolean isFatalEnabled() { + return true; + } + + /** + * @see org.apache.commons.logging.Log#isInfoEnabled() + */ + @Override + public boolean isInfoEnabled() { + return false; + } + + /** + * @see org.apache.commons.logging.Log#isTraceEnabled() + */ + @Override + public boolean isTraceEnabled() { + return false; + } + + /** + * @see org.apache.commons.logging.Log#isWarnEnabled() + */ + @Override + public boolean isWarnEnabled() { + return false; + } + + /** + * @see org.apache.commons.logging.Log#trace(java.lang.Object) + */ + @Override + public void trace(Object message) { + } + + /** + * @see org.apache.commons.logging.Log#trace(java.lang.Object, java.lang.Throwable) + */ + @Override + public void trace(Object message, Throwable t) { + } + + /** + * @see org.apache.commons.logging.Log#warn(java.lang.Object) + */ + @Override + public void warn(Object message) { + } + + /** + * @see org.apache.commons.logging.Log#warn(java.lang.Object, java.lang.Throwable) + */ + @Override + public void warn(Object message, Throwable t) { + } +} Propchange: incubator/rat/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/rat/whisker/cli/SystemLog.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/rat/whisker/trunk/apache-whisker-plugin4maven/pom.xml URL: http://svn.apache.org/viewvc/incubator/rat/whisker/trunk/apache-whisker-plugin4maven/pom.xml?rev=1225155&r1=1225154&r2=1225155&view=diff ============================================================================== --- incubator/rat/whisker/trunk/apache-whisker-plugin4maven/pom.xml (original) +++ incubator/rat/whisker/trunk/apache-whisker-plugin4maven/pom.xml Wed Dec 28 10:30:18 2011 @@ -40,6 +40,16 @@ maven-plugin-api 2.0 + + + org.apache.commons + commons-lang3 + + + + commons-logging + commons-logging-api + junit Modified: incubator/rat/whisker/trunk/apache-whisker-plugin4maven/src/main/java/org/apache/rat/whisker/plugin/maven/GenerateMojo.java URL: http://svn.apache.org/viewvc/incubator/rat/whisker/trunk/apache-whisker-plugin4maven/src/main/java/org/apache/rat/whisker/plugin/maven/GenerateMojo.java?rev=1225155&r1=1225154&r2=1225155&view=diff ============================================================================== --- incubator/rat/whisker/trunk/apache-whisker-plugin4maven/src/main/java/org/apache/rat/whisker/plugin/maven/GenerateMojo.java (original) +++ incubator/rat/whisker/trunk/apache-whisker-plugin4maven/src/main/java/org/apache/rat/whisker/plugin/maven/GenerateMojo.java Wed Dec 28 10:30:18 2011 @@ -69,7 +69,7 @@ public class GenerateMojo extends Abstra if (descriptor.canRead()) { try { new Whisker().setLicenseDescriptor(new StreamableResourceFactory().streamFromFileResource(descriptor)) - .setEngine(new VelocityEngine()) + .setEngine(new VelocityEngine(new MojoToJCLLog(getLog()))) .setWriterFactory(new WriteResultsIntoDirectoryFactory(outputDirectory, outputEncoding)) .setAct(Act.GENERATE).act(); } catch (Exception e) { Added: incubator/rat/whisker/trunk/apache-whisker-plugin4maven/src/main/java/org/apache/rat/whisker/plugin/maven/MojoToJCLLog.java URL: http://svn.apache.org/viewvc/incubator/rat/whisker/trunk/apache-whisker-plugin4maven/src/main/java/org/apache/rat/whisker/plugin/maven/MojoToJCLLog.java?rev=1225155&view=auto ============================================================================== --- incubator/rat/whisker/trunk/apache-whisker-plugin4maven/src/main/java/org/apache/rat/whisker/plugin/maven/MojoToJCLLog.java (added) +++ incubator/rat/whisker/trunk/apache-whisker-plugin4maven/src/main/java/org/apache/rat/whisker/plugin/maven/MojoToJCLLog.java Wed Dec 28 10:30:18 2011 @@ -0,0 +1,180 @@ +/** + * 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. + */ +package org.apache.rat.whisker.plugin.maven; + +import org.apache.commons.lang3.ObjectUtils; +import org.apache.maven.plugin.logging.Log; + +/** + * + */ +public class MojoToJCLLog implements org.apache.commons.logging.Log { + + private final Log log; + + public MojoToJCLLog(Log log) { + super(); + this.log = log; + } + + /** + * @see org.apache.commons.logging.Log#debug(java.lang.Object) + */ + @Override + public void debug(Object message) { + log.debug(ObjectUtils.toString(message)); + } + + /** + * @see org.apache.commons.logging.Log#debug(java.lang.Object, java.lang.Throwable) + */ + @Override + public void debug(Object message, Throwable t) { + log.debug(ObjectUtils.toString(message), t); + } + + /** + * @see org.apache.commons.logging.Log#error(java.lang.Object) + */ + @Override + public void error(Object message) { + log.error(ObjectUtils.toString(message)); + } + + /** + * @see org.apache.commons.logging.Log#error(java.lang.Object, java.lang.Throwable) + */ + @Override + public void error(Object message, Throwable t) { + log.error(ObjectUtils.toString(message), t); + } + + /** + * @see org.apache.commons.logging.Log#fatal(java.lang.Object) + */ + @Override + public void fatal(Object message) { + log.error(ObjectUtils.toString(message)); + } + + /** + * @see org.apache.commons.logging.Log#fatal(java.lang.Object, java.lang.Throwable) + */ + @Override + public void fatal(Object message, Throwable t) { + log.error(ObjectUtils.toString(message), t); + } + + /** + * @see org.apache.commons.logging.Log#info(java.lang.Object) + */ + @Override + public void info(Object message) { + log.info(ObjectUtils.toString(message)); + } + + /** + * @see org.apache.commons.logging.Log#info(java.lang.Object, java.lang.Throwable) + */ + @Override + public void info(Object message, Throwable t) { + log.info(ObjectUtils.toString(message), t); + } + + /** + * @see org.apache.commons.logging.Log#isDebugEnabled() + */ + @Override + public boolean isDebugEnabled() { + return log.isDebugEnabled(); + } + + /** + * @see org.apache.commons.logging.Log#isErrorEnabled() + */ + @Override + public boolean isErrorEnabled() { + return log.isErrorEnabled(); + } + + /** + * @see org.apache.commons.logging.Log#isFatalEnabled() + */ + @Override + public boolean isFatalEnabled() { + return log.isErrorEnabled(); + } + + /** + * @see org.apache.commons.logging.Log#isInfoEnabled() + */ + @Override + public boolean isInfoEnabled() { + return log.isInfoEnabled(); + } + + /** + * @see org.apache.commons.logging.Log#isTraceEnabled() + */ + @Override + public boolean isTraceEnabled() { + return log.isDebugEnabled(); + } + + /** + * @see org.apache.commons.logging.Log#isWarnEnabled() + */ + @Override + public boolean isWarnEnabled() { + return log.isWarnEnabled(); + } + + /** + * @see org.apache.commons.logging.Log#trace(java.lang.Object) + */ + @Override + public void trace(Object message) { + log.debug(ObjectUtils.toString(message)); + } + + /** + * @see org.apache.commons.logging.Log#trace(java.lang.Object, java.lang.Throwable) + */ + @Override + public void trace(Object message, Throwable t) { + log.debug(ObjectUtils.toString(message), t); + } + + /** + * @see org.apache.commons.logging.Log#warn(java.lang.Object) + */ + @Override + public void warn(Object message) { + log.warn(ObjectUtils.toString(message)); + } + + /** + * @see org.apache.commons.logging.Log#warn(java.lang.Object, java.lang.Throwable) + */ + @Override + public void warn(Object message, Throwable t) { + log.warn(ObjectUtils.toString(message), t); + } + +} Propchange: incubator/rat/whisker/trunk/apache-whisker-plugin4maven/src/main/java/org/apache/rat/whisker/plugin/maven/MojoToJCLLog.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/rat/whisker/trunk/apache-whisker-velocity/pom.xml URL: http://svn.apache.org/viewvc/incubator/rat/whisker/trunk/apache-whisker-velocity/pom.xml?rev=1225155&r1=1225154&r2=1225155&view=diff ============================================================================== --- incubator/rat/whisker/trunk/apache-whisker-velocity/pom.xml (original) +++ incubator/rat/whisker/trunk/apache-whisker-velocity/pom.xml Wed Dec 28 10:30:18 2011 @@ -49,6 +49,11 @@ commons-io commons-io + + + commons-logging + commons-logging-api + junit Modified: incubator/rat/whisker/trunk/apache-whisker-velocity/src/main/java/org/apache/rat/whisker/out/velocity/VelocityEngine.java URL: http://svn.apache.org/viewvc/incubator/rat/whisker/trunk/apache-whisker-velocity/src/main/java/org/apache/rat/whisker/out/velocity/VelocityEngine.java?rev=1225155&r1=1225154&r2=1225155&view=diff ============================================================================== --- incubator/rat/whisker/trunk/apache-whisker-velocity/src/main/java/org/apache/rat/whisker/out/velocity/VelocityEngine.java (original) +++ incubator/rat/whisker/trunk/apache-whisker-velocity/src/main/java/org/apache/rat/whisker/out/velocity/VelocityEngine.java Wed Dec 28 10:30:18 2011 @@ -20,6 +20,7 @@ package org.apache.rat.whisker.out.veloc import java.util.Collection; +import org.apache.commons.logging.Log; import org.apache.rat.whisker.app.AbstractEngine; import org.apache.rat.whisker.app.ResultWriterFactory; import org.apache.rat.whisker.app.analysis.LicenseAnalyst; @@ -30,6 +31,13 @@ import org.apache.rat.whisker.scan.Direc * */ public class VelocityEngine extends AbstractEngine { + + private final Log log; + + public VelocityEngine(Log log) { + super(); + this.log = log; + } /** * @see org.apache.rat.whisker.app.AbstractEngine#generateTemplate(java.util.Collection, ResultWriterFactory) @@ -37,16 +45,24 @@ public class VelocityEngine extends Abst @Override public AbstractEngine generateTemplate(Collection withBase, ResultWriterFactory writerFactory) throws Exception { - new VelocityReports(writerFactory).generateTemplate(withBase); + reporter(writerFactory).generateTemplate(withBase); return this; } /** + * @param writerFactory + * @return + */ + private VelocityReports reporter(ResultWriterFactory writerFactory) { + return new VelocityReports(writerFactory, log); + } + + /** * @see org.apache.rat.whisker.app.AbstractEngine#validate(org.apache.rat.whisker.app.LicenseAnalyst, ResultWriterFactory) */ @Override public AbstractEngine validate(LicenseAnalyst analyst, ResultWriterFactory writerFactory) throws Exception { - new VelocityReports(writerFactory).validate(analyst); + reporter(writerFactory).validate(analyst); return this; } @@ -56,7 +72,7 @@ public class VelocityEngine extends Abst @Override public AbstractEngine report(Collection directories, ResultWriterFactory writerFactory) throws Exception { - new VelocityReports(writerFactory).report(directories); + reporter(writerFactory).report(directories); return this; } @@ -65,7 +81,7 @@ public class VelocityEngine extends Abst */ @Override public AbstractEngine generate(Descriptor work, ResultWriterFactory writerFactory) throws Exception { - new VelocityReports(writerFactory).generate(work); + reporter(writerFactory).generate(work); return this; } Modified: incubator/rat/whisker/trunk/apache-whisker-velocity/src/main/java/org/apache/rat/whisker/out/velocity/VelocityReports.java URL: http://svn.apache.org/viewvc/incubator/rat/whisker/trunk/apache-whisker-velocity/src/main/java/org/apache/rat/whisker/out/velocity/VelocityReports.java?rev=1225155&r1=1225154&r2=1225155&view=diff ============================================================================== --- incubator/rat/whisker/trunk/apache-whisker-velocity/src/main/java/org/apache/rat/whisker/out/velocity/VelocityReports.java (original) +++ incubator/rat/whisker/trunk/apache-whisker-velocity/src/main/java/org/apache/rat/whisker/out/velocity/VelocityReports.java Wed Dec 28 10:30:18 2011 @@ -23,6 +23,7 @@ import java.io.Writer; import java.util.Collection; import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; import org.apache.rat.whisker.app.ResultWriterFactory; import org.apache.rat.whisker.app.analysis.LicenseAnalyst; import org.apache.rat.whisker.app.analysis.ResourceDefinitionException; @@ -48,9 +49,11 @@ public class VelocityReports implements private final ResultWriterFactory writerFactory; private final VelocityEngine engine; + private final Log log; - public VelocityReports(final ResultWriterFactory writerFactory) { + public VelocityReports(final ResultWriterFactory writerFactory, final Log log) { this.writerFactory = writerFactory; + this.log = log; engine = new VelocityEngine(); engine.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, this); engine.setProperty(VelocityEngine.RESOURCE_LOADER, "classpath"); @@ -69,7 +72,19 @@ public class VelocityReports implements */ @Override public boolean isLevelEnabled(int level) { - return true; + switch (level) { + case DEBUG_ID: + return log.isDebugEnabled(); + case TRACE_ID: + return log.isTraceEnabled(); + case INFO_ID: + return log.isInfoEnabled(); + case WARN_ID: + return log.isWarnEnabled(); + case ERROR_ID: + return log.isErrorEnabled(); + } + return false; } /** @@ -77,7 +92,23 @@ public class VelocityReports implements */ @Override public void log(int level, String message) { - System.err.println(message); + switch (level) { + case DEBUG_ID: + log.debug(message); + break; + case TRACE_ID: + log.trace(message); + break; + case INFO_ID: + log.info(message); + break; + case WARN_ID: + log.warn(message); + break; + case ERROR_ID: + log.error(message); + break; + } } /** @@ -85,9 +116,23 @@ public class VelocityReports implements */ @Override public void log(int level, String message, Throwable throwable) { - System.err.println(message); - throwable.printStackTrace(); - } + switch (level) { + case DEBUG_ID: + log.debug(message, throwable); + break; + case TRACE_ID: + log.trace(message, throwable); + break; + case INFO_ID: + log.info(message, throwable); + break; + case WARN_ID: + log.warn(message, throwable); + break; + case ERROR_ID: + log.error(message, throwable); + break; + } } /** * Modified: incubator/rat/whisker/trunk/pom.xml URL: http://svn.apache.org/viewvc/incubator/rat/whisker/trunk/pom.xml?rev=1225155&r1=1225154&r2=1225155&view=diff ============================================================================== --- incubator/rat/whisker/trunk/pom.xml (original) +++ incubator/rat/whisker/trunk/pom.xml Wed Dec 28 10:30:18 2011 @@ -65,6 +65,12 @@ + commons-logging + commons-logging-api + 1.1 + + + junit junit 3.8.1