diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index 7f506ad430..565f6a93f7 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -41,11 +41,11 @@ THE SOFTWARE. http://wiki.jenkins-ci.org/display/JENKINS/Maven+Project+Plugin - 1.3 + 1.4-SNAPSHOT 3.1.0 ${mavenVersion} 0.9.0.M2 - 2.3.0 + 0.0.0.M2a 2.4 @@ -176,11 +176,11 @@ THE SOFTWARE. plexus-container-default - - + + - org.sonatype.sisu - sisu-inject-plexus + org.eclipse.sisu + org.eclipse.sisu.plexus ${sisuInjectVersion} @@ -200,19 +200,6 @@ THE SOFTWARE. - - org.sonatype.sisu - sisu-inject-bean - ${sisuInjectVersion} - - - - org.sonatype.sisu - sisu-guice - - - - org.apache.maven.wagon diff --git a/maven-plugin/src/main/java/hudson/maven/EmbedderLoggerImpl.java b/maven-plugin/src/main/java/hudson/maven/EmbedderLoggerImpl.java deleted file mode 100644 index 13a0944565..0000000000 --- a/maven-plugin/src/main/java/hudson/maven/EmbedderLoggerImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Tom Huybrechts - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package hudson.maven; - -import hudson.model.TaskListener; - -import java.io.PrintStream; -import java.util.StringTokenizer; - -import org.apache.maven.cli.MavenLoggerManager; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.console.ConsoleLogger; - -/** - * {@link MavenEmbedderLogger} implementation that - * sends output to {@link TaskListener}. - * - * @author Kohsuke Kawaguchi - */ -// TODO this is gone in 3.1.0, replaced by SLF4J -public final class EmbedderLoggerImpl extends MavenLoggerManager { - private final PrintStream logger; - - public EmbedderLoggerImpl(TaskListener listener, int threshold) { - super(new ConsoleLogger( threshold, "hudson-logger" )); - logger = listener.getLogger(); - } - - private void print(String message, Throwable throwable, int threshold, String prefix) { - if (getThreshold() <= threshold) { - StringTokenizer tokens = new StringTokenizer(message,"\n"); - while(tokens.hasMoreTokens()) { - logger.print(prefix); - logger.println(tokens.nextToken()); - } - - if (throwable!=null) - throwable.printStackTrace(logger); - } - } - - public void debug(String message, Throwable throwable) { - print(message, throwable, Logger.LEVEL_DEBUG, "[DEBUG] "); - } - - public void info(String message, Throwable throwable) { - print(message, throwable, Logger.LEVEL_INFO, "[INFO ] "); - } - - public void warn(String message, Throwable throwable) { - print(message, throwable, Logger.LEVEL_WARN, "[WARN ] "); - } - - public void error(String message, Throwable throwable) { - print(message, throwable, Logger.LEVEL_ERROR, "[ERROR] "); - } - - public void fatalError(String message, Throwable throwable) { - print(message, throwable, Logger.LEVEL_FATAL, "[FATAL] "); - } -} diff --git a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java index 4ce94f7a99..ceec1507a8 100644 --- a/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java +++ b/maven-plugin/src/main/java/hudson/maven/Maven3Builder.java @@ -25,13 +25,12 @@ package hudson.maven; import hudson.maven.MavenBuild.ProxyImpl2; import hudson.maven.reporters.TestFailureDetector; -import hudson.maven.util.ExecutionEventLogger; import hudson.model.BuildListener; import hudson.model.Result; import hudson.remoting.Channel; import hudson.remoting.DelegatingCallable; import hudson.util.IOException2; -import org.apache.maven.cli.PrintStreamLogger; +import org.apache.maven.cli.event.ExecutionEventLogger; import org.apache.maven.execution.AbstractExecutionListener; import org.apache.maven.execution.ExecutionEvent; import org.apache.maven.execution.ExecutionListener; @@ -41,6 +40,7 @@ import org.apache.maven.project.MavenProject; import org.jvnet.hudson.maven3.agent.Maven3Main; import org.jvnet.hudson.maven3.launcher.Maven3Launcher; import org.jvnet.hudson.maven3.listeners.HudsonMavenExecutionResult; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.io.PrintStream; @@ -173,6 +173,8 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal private final AbstractMavenBuilder maven3Builder; private AtomicBoolean hasTestFailures = new AtomicBoolean(); + + private org.slf4j.Logger logger = LoggerFactory.getLogger( MavenExecutionListener.class ); /** * Number of total nanoseconds {@link Maven3Builder} spent. @@ -198,16 +200,9 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal } this.reporters = new ConcurrentHashMap>(maven3Builder.reporters); - // TODO: we should think about reusing the code in org.apache.maven.cli.DefaultMavenExecutionRequestBuilder#logging? + // E.g. there's also the option to redirect logging to a file which is handled there, but not here. - // TODO replace with SLF4J - PrintStreamLogger logger = new PrintStreamLogger( maven3Builder.listener.getLogger() ); - if (maven3Builder.isDebug()) { - logger.setThreshold(PrintStreamLogger.LEVEL_DEBUG); - } else if (maven3Builder.isQuiet()) { - logger.setThreshold(PrintStreamLogger.LEVEL_ERROR); - } - + this.eventLogger = new ExecutionEventLogger( logger ); } diff --git a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java index 7c5d6e2355..0478ac9ab2 100755 --- a/maven-plugin/src/main/java/hudson/maven/MavenUtil.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenUtil.java @@ -23,23 +23,26 @@ */ package hudson.maven; +import edu.umd.cs.findbugs.annotations.SuppressWarnings; import hudson.AbortException; import hudson.FilePath; import hudson.Util; import hudson.model.AbstractBuild; import hudson.model.AbstractProject; import hudson.model.BuildListener; -import hudson.util.MaskingClassLoader; -import jenkins.model.Jenkins; -import jenkins.mvn.SettingsProvider; import hudson.model.TaskListener; import hudson.tasks.Maven.MavenInstallation; import hudson.tasks.Maven.ProjectWithMaven; +import jenkins.model.Jenkins; +import jenkins.mvn.SettingsProvider; +import org.apache.commons.lang.StringUtils; +import org.apache.maven.artifact.versioning.ComparableVersion; +import org.apache.maven.cli.logging.Slf4jLoggerManager; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.ProjectBuildingException; -import java.io.BufferedReader; import java.io.File; import java.io.IOException; -import java.io.InputStreamReader; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; @@ -49,14 +52,6 @@ import java.util.Map; import java.util.Properties; import java.util.logging.Logger; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.maven.artifact.versioning.ComparableVersion; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.ProjectBuildingException; - -import edu.umd.cs.findbugs.annotations.SuppressWarnings; - /** * @author Kohsuke Kawaguchi */ @@ -191,10 +186,8 @@ public class MavenUtil { } mavenRequest.setTransferListener( mer.getTransferListener() ); } - EmbedderLoggerImpl logger = - new EmbedderLoggerImpl( mer.getListener(), debugMavenEmbedder ? org.codehaus.plexus.logging.Logger.LEVEL_DEBUG - : org.codehaus.plexus.logging.Logger.LEVEL_INFO ); - mavenRequest.setMavenLoggerManager( logger ); + + mavenRequest.setMavenLoggerManager( new Slf4jLoggerManager() ); ClassLoader mavenEmbedderClassLoader = mer.getClassLoader(); diff --git a/maven-plugin/src/main/java/hudson/maven/util/ExecutionEventLogger.java b/maven-plugin/src/main/java/hudson/maven/util/ExecutionEventLogger.java index d594360220..0054f4fef1 100644 --- a/maven-plugin/src/main/java/hudson/maven/util/ExecutionEventLogger.java +++ b/maven-plugin/src/main/java/hudson/maven/util/ExecutionEventLogger.java @@ -40,7 +40,7 @@ import org.codehaus.plexus.logging.Logger; * * @author Benjamin Bentmann */ -// Note: copied from package org.apache.maven.cli with just one minor adaption for Maven3MojoNote +// Note: copied from package org.apache.maven.cli with just one minor adaption for Maven3Mojo public class ExecutionEventLogger extends AbstractExecutionListener { diff --git a/pom.xml b/pom.xml index 4c2ed2e39f..00a549197b 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ THE SOFTWARE. https://api.github.com jenkins-jira - 1.6.2 + 1.7.4 none ${skipTests}