Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/main/java/hudson/maven/MavenBuild.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import jenkins.maven3.agent.Maven32Main;
import jenkins.maven3.agent.Maven33Main;

import org.apache.commons.io.output.NullOutputStream;
import org.apache.maven.BuildFailureException;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.ReactorManager;
Expand All @@ -75,8 +76,6 @@
import org.kohsuke.stapler.export.Exported;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Serializable;
Expand Down Expand Up @@ -590,10 +589,10 @@ public class ProxyImpl2 extends ProxyImpl implements MavenBuildProxy2 {
private final MavenModuleSetBuild parentBuild;
private boolean blockBuildEvents;

ProxyImpl2(MavenModuleSetBuild parentBuild,SplittableBuildListener listener) throws FileNotFoundException {
ProxyImpl2(MavenModuleSetBuild parentBuild, SplittableBuildListener listener, OutputStream log) {
this.parentBuild = parentBuild;
this.listener = listener;
log = new FileOutputStream(getLogFile()); // no buffering so that AJAX clients can see the log live
this.log = log;
}

public void start() {
Expand Down Expand Up @@ -896,7 +895,7 @@ protected Result doRun(BuildListener listener) throws Exception {
ProxyImpl proxy;
if (mavenBuildInformation.isMaven3OrLater())
{
ProxyImpl2 proxy2 = new ProxyImpl2(mms.getLastCompletedBuild(), slistener);
ProxyImpl2 proxy2 = new ProxyImpl2(mms.getLastCompletedBuild(), slistener, new NullOutputStream());
proxy2.setBlockBuildEvents(true);
proxy = proxy2;
builder = new Maven3Builder(createRequest(proxy2,
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/hudson/maven/MavenModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import hudson.maven.reporters.MavenMailer;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.BuildableItemWithBuildWrappers;
import hudson.model.DependencyGraph;
import hudson.model.Descriptor;
import hudson.model.Descriptor.FormException;
Expand All @@ -43,6 +44,7 @@
import hudson.model.Node;
import hudson.model.Resource;
import hudson.model.Saveable;
import hudson.tasks.BuildWrapper;
import hudson.tasks.LogRotator;
import hudson.tasks.Maven.MavenInstallation;
import hudson.tasks.Publisher;
Expand Down Expand Up @@ -77,7 +79,7 @@
*
* @author Kohsuke Kawaguchi
*/
public class MavenModule extends AbstractMavenProject<MavenModule,MavenBuild> implements Saveable {
public class MavenModule extends AbstractMavenProject<MavenModule,MavenBuild> implements Saveable, BuildableItemWithBuildWrappers {
private DescribableList<MavenReporter,Descriptor<MavenReporter>> reporters =
new DescribableList<MavenReporter,Descriptor<MavenReporter>>(this);

Expand Down Expand Up @@ -794,6 +796,17 @@ public Set<ModuleDependency> getDependencies() {
return new HashSet<ModuleDependency>( dependencies);
}

@Override
public AbstractProject<?, ?> asProject() {
return this;
}

@Override
public DescribableList<BuildWrapper, Descriptor<BuildWrapper>> getBuildWrappersList() {
// inherit build wrappers configured on the parent project
return getParent().getBuildWrappersList();
}

/**
* for debug purpose
*/
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/hudson/maven/MavenModuleSetBuild.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import hudson.EnvVars;
import hudson.FilePath;
import hudson.Util;
import hudson.console.ConsoleLogFilter;
import hudson.maven.MavenBuild.ProxyImpl2;
import hudson.maven.reporters.MavenAggregatedArtifactRecord;
import hudson.maven.reporters.MavenFingerprinter;
Expand Down Expand Up @@ -63,8 +64,10 @@
import hudson.util.StreamTaskListener;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.Serializable;
import java.net.URL;
Expand Down Expand Up @@ -730,7 +733,7 @@ protected Result doRun(final BuildListener listener) throws Exception {
}

mb.setWorkspace(getModuleRoot().child(m.getRelativePath()));
proxies.put(moduleName, mb.new ProxyImpl2(MavenModuleSetBuild.this,slistener));
proxies.put(moduleName, mb.new ProxyImpl2(MavenModuleSetBuild.this, slistener, createModuleLogger(mb)));
}

// run the complete build here
Expand Down Expand Up @@ -1063,6 +1066,22 @@ private void parsePoms(BuildListener listener, PrintStream logger, EnvVars envVa
m.updateNextBuildNumber(getNumber());
}

private OutputStream createModuleLogger(MavenBuild build) throws IOException, InterruptedException {
OutputStream logger = new FileOutputStream(build.getLogFile()); // no buffering so that AJAX clients can see the log live

// Global log filters
for (ConsoleLogFilter filter : ConsoleLogFilter.all()) {
logger = filter.decorateLogger(build, logger);
}

// Project specific log filters
for (BuildWrapper bw : getParent().getBuildWrappersList()) {
logger = bw.decorateLogger(build, logger);
}

return logger;
}

protected void post2(BuildListener listener) throws Exception {
// asynchronous executions from the build might have left some unsaved state,
// so just to be safe, save them all.
Expand Down