From 9186e0e169d9c134395bf99de852a75d06897d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Mon, 15 Jan 2024 09:44:30 +0100 Subject: [PATCH] Add option to not print markers to the maven log (cherry picked from commit 44fecdd257a232c8053b30c65726f6d6fb0268cb) --- .../tycho/eclipsebuild/EclipseBuildMojo.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tycho-eclipse-plugin/src/main/java/org/eclipse/tycho/eclipsebuild/EclipseBuildMojo.java b/tycho-eclipse-plugin/src/main/java/org/eclipse/tycho/eclipsebuild/EclipseBuildMojo.java index a2ccc685ea..883e196016 100644 --- a/tycho-eclipse-plugin/src/main/java/org/eclipse/tycho/eclipsebuild/EclipseBuildMojo.java +++ b/tycho-eclipse-plugin/src/main/java/org/eclipse/tycho/eclipsebuild/EclipseBuildMojo.java @@ -25,6 +25,7 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -74,6 +75,9 @@ public class EclipseBuildMojo extends AbstractMojo { @Parameter(defaultValue = "true", property = "tycho.eclipsebuild.failOnError") private boolean failOnError; + @Parameter(defaultValue = "true", property = "tycho.eclipsebuild.printMarker") + private boolean printMarker; + @Parameter private List bundles; @@ -125,13 +129,16 @@ public void execute() throws MojoExecutionException, MojoFailureException { } EclipseBuildResult result = framework .execute(new EclipseBuild(project.getBasedir().toPath(), debug)); - result.markers().filter(marker -> marker.getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_INFO) - .forEach(info -> printMarker(info, result, getLog()::info)); - result.markers().filter(marker -> marker.getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_WARNING) - .forEach(warn -> printMarker(warn, result, getLog()::warn)); - List errors = result.markers() - .filter(marker -> marker.getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR).toList(); - errors.forEach(error -> printMarker(error, result, getLog()::error)); + List errors = result.markers() + .filter(marker -> marker.getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR).toList(); + if (printMarker) { + Log log = getLog(); + result.markers().filter(marker -> marker.getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_INFO) + .forEach(info -> printMarker(info, result, log::info)); + result.markers().filter(marker -> marker.getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_WARNING) + .forEach(warn -> printMarker(warn, result, log::warn)); + errors.forEach(error -> printMarker(error, result, log::error)); + } if (failOnError && errors.size() > 0) { String msg = errors.stream().map(problem -> asString(problem, result)) .collect(Collectors.joining(System.lineSeparator()));