Skip to content

Commit

Permalink
[FIXED JENKINS-16843] Maven 3 builds ignored quiet (-q) and debug (-X…
Browse files Browse the repository at this point in the history
…) flags

Originally-Committed-As: cff691e05a415c860396b9d369c82e01b4aef69d
  • Loading branch information
kutzi committed Feb 16, 2013
1 parent 837f55b commit 768a5b2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
14 changes: 14 additions & 0 deletions src/main/java/hudson/maven/AbstractMavenBuilder.java
Expand Up @@ -199,6 +199,20 @@ protected Result waitForAsynchronousExecutions() {
}
}

protected boolean isDebug() {
for(String goal : goals) {
if (goal.equals("-X") || goal.equals("--debug")) return true;
}
return false;
}

protected boolean isQuiet() {
for(String goal : goals) {
if (goal.equals("-q") || goal.equals("--quiet")) return true;
}
return false;
}

protected static class FilterImpl extends MavenBuildProxy2.Filter<MavenBuildProxy2> implements Serializable {

private MavenBuildInformation mavenBuildInformation;
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/hudson/maven/Maven3Builder.java
Expand Up @@ -167,7 +167,7 @@ private static final class MavenExecutionListener extends AbstractExecutionListe

private static final long serialVersionUID = 4942789836756366116L;

private final Maven3Builder maven3Builder;
private final AbstractMavenBuilder maven3Builder;

private AtomicBoolean hasTestFailures = new AtomicBoolean();

Expand All @@ -187,14 +187,24 @@ private static final class MavenExecutionListener extends AbstractExecutionListe

private ExecutionEventLogger eventLogger;

public MavenExecutionListener(Maven3Builder maven3Builder) {
public MavenExecutionListener(AbstractMavenBuilder maven3Builder) {
this.maven3Builder = maven3Builder;
this.proxies = new ConcurrentHashMap<ModuleName, FilterImpl>(maven3Builder.proxies);
for (ModuleName name : this.proxies.keySet()) {
executedMojosPerModule.put( name, new CopyOnWriteArrayList<ExecutedMojo>() );
}
this.reporters = new ConcurrentHashMap<ModuleName, List<MavenReporter>>(maven3Builder.reporters);
this.eventLogger = new ExecutionEventLogger( new PrintStreamLogger( maven3Builder.listener.getLogger() ) );

// 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.
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 );
}

/**
Expand Down

0 comments on commit 768a5b2

Please sign in to comment.