mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-17 22:12:25 +00:00
first cut at the aggregated build.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@4440 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
afbe0d2c47
commit
7b02693fb1
3 files changed
+96
-11
No files matched your search
@@ -197,7 +197,7 @@ public class MavenBuild extends AbstractBuild<MavenModule,MavenBuild> {
|
||||
/**
|
||||
* {@link MavenBuildProxy} implementation.
|
||||
*/
|
||||
final class ProxyImpl implements MavenBuildProxy, Serializable {
|
||||
class ProxyImpl implements MavenBuildProxy, Serializable {
|
||||
public <V, T extends Throwable> V execute(BuildCallable<V, T> program) throws T, IOException, InterruptedException {
|
||||
return program.call(MavenBuild.this);
|
||||
}
|
||||
@@ -227,7 +227,49 @@ public class MavenBuild extends AbstractBuild<MavenModule,MavenBuild> {
|
||||
}
|
||||
|
||||
private Object writeReplace() {
|
||||
return Channel.current().export(MavenBuildProxy.class, new ProxyImpl());
|
||||
return Channel.current().export(MavenBuildProxy.class,this);
|
||||
}
|
||||
}
|
||||
|
||||
class ProxyImpl2 extends ProxyImpl implements MavenBuildProxy2 {
|
||||
long startTime;
|
||||
public void start() {
|
||||
onStartBuilding();
|
||||
startTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void end() {
|
||||
if(result==null)
|
||||
setResult(Result.SUCCESS);
|
||||
onEndBuilding();
|
||||
duration = System.currentTimeMillis()- startTime;
|
||||
try {
|
||||
save();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the build as aborted. This method is used when the aggregated build
|
||||
* failed before it didn't even get to this module.
|
||||
*/
|
||||
protected void abortIfNotStarted() {
|
||||
if(hasntStartedYet()) {
|
||||
run(new Runner() {
|
||||
public Result run(BuildListener listener) throws Exception, RunnerAbortedException {
|
||||
listener.getLogger().println("Build failed before it gets to this module");
|
||||
return Result.ABORTED;
|
||||
}
|
||||
|
||||
public void post(BuildListener listener) throws Exception {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private Object writeReplace() {
|
||||
return Channel.current().export(MavenBuildProxy2.class,this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package hudson.maven;
|
||||
|
||||
/**
|
||||
* A part of {@link MavenBuildProxy} that's used internally
|
||||
* for aggregated build. Fired and consumed internally and
|
||||
* not exposed to plugins.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
interface MavenBuildProxy2 extends MavenBuildProxy {
|
||||
/**
|
||||
* Notifies that the build has entered a module.
|
||||
*/
|
||||
void start();
|
||||
|
||||
/**
|
||||
* Notifies that the build has left a module.
|
||||
*/
|
||||
void end();
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package hudson.maven;
|
||||
|
||||
import hudson.AbortException;
|
||||
import hudson.maven.MavenBuild.ProxyImpl2;
|
||||
import hudson.FilePath.FileCallable;
|
||||
import hudson.model.AbstractBuild;
|
||||
import hudson.model.Action;
|
||||
@@ -277,9 +278,9 @@ public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,Mave
|
||||
logger.println("Triggering "+project.getRootModule().getModuleName());
|
||||
project.getRootModule().scheduleBuild();
|
||||
} else {
|
||||
Map<ModuleName,MavenBuild.ProxyImpl> proxies = new HashMap<ModuleName,MavenBuild.ProxyImpl>();
|
||||
Map<ModuleName,MavenBuild.ProxyImpl2> proxies = new HashMap<ModuleName,MavenBuild.ProxyImpl2>();
|
||||
for (MavenModule m : modules.values())
|
||||
proxies.put(m.getModuleName(),m.newBuild().new ProxyImpl());
|
||||
proxies.put(m.getModuleName(),m.newBuild().new ProxyImpl2());
|
||||
|
||||
// run the complete build here
|
||||
Map<String,String> envVars = getEnvVars();
|
||||
@@ -288,13 +289,15 @@ public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,Mave
|
||||
new MavenProcessFactory(project,launcher,envVars));
|
||||
|
||||
ArgumentListBuilder margs = new ArgumentListBuilder();
|
||||
margs.add("-B").add("-f",project.getRootPOM());
|
||||
margs.add("-B").add("-f",project.getModuleRoot().child(project.getRootPOM()).getRemote());
|
||||
margs.addTokenized(project.getGoals());
|
||||
|
||||
try {
|
||||
return process.channel.call(new Builder(
|
||||
listener,proxies,modules.values(),margs.toList(),envVars));
|
||||
} finally {
|
||||
for (ProxyImpl2 p : proxies.values())
|
||||
p.abortIfNotStarted();
|
||||
process.discard();
|
||||
}
|
||||
}
|
||||
@@ -327,10 +330,10 @@ public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,Mave
|
||||
* Runs Maven and builds the project.
|
||||
*/
|
||||
private static final class Builder extends MavenBuilder {
|
||||
private final Map<ModuleName,? extends MavenBuildProxy> buildProxy;
|
||||
private final Map<ModuleName,? extends MavenBuildProxy2> buildProxy;
|
||||
private final Map<ModuleName,List<MavenReporter>> reporters = new HashMap<ModuleName,List<MavenReporter>>();
|
||||
|
||||
public Builder(BuildListener listener,Map<ModuleName,? extends MavenBuildProxy> buildProxy, Collection<MavenModule> modules, List<String> goals, Map<String,String> systemProps) {
|
||||
public Builder(BuildListener listener,Map<ModuleName,? extends MavenBuildProxy2> buildProxy, Collection<MavenModule> modules, List<String> goals, Map<String,String> systemProps) {
|
||||
super(listener,goals,systemProps);
|
||||
this.buildProxy = buildProxy;
|
||||
|
||||
@@ -347,19 +350,39 @@ public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,Mave
|
||||
}
|
||||
|
||||
void preModule(MavenProject project) throws InterruptedException, IOException, hudson.maven.agent.AbortException {
|
||||
// TODO
|
||||
ModuleName name = new ModuleName(project);
|
||||
MavenBuildProxy2 proxy = buildProxy.get(name);
|
||||
proxy.start();
|
||||
for (MavenReporter r : reporters.get(name))
|
||||
if(!r.preBuild(proxy,project,listener))
|
||||
throw new hudson.maven.agent.AbortException(r+" failed");
|
||||
}
|
||||
|
||||
void postModule(MavenProject project) throws InterruptedException, IOException, hudson.maven.agent.AbortException {
|
||||
// TODO
|
||||
ModuleName name = new ModuleName(project);
|
||||
MavenBuildProxy2 proxy = buildProxy.get(name);
|
||||
for (MavenReporter r : reporters.get(name))
|
||||
if(!r.postBuild(proxy,project,listener))
|
||||
throw new hudson.maven.agent.AbortException(r+" failed");
|
||||
proxy.end();
|
||||
}
|
||||
|
||||
void preExecute(MavenProject project, MojoInfo mojoInfo) throws IOException, InterruptedException, hudson.maven.agent.AbortException {
|
||||
// TODO
|
||||
ModuleName name = new ModuleName(project);
|
||||
MavenBuildProxy proxy = buildProxy.get(name);
|
||||
for (MavenReporter r : reporters.get(name))
|
||||
if(!r.preExecute(proxy,project,mojoInfo,listener))
|
||||
throw new hudson.maven.agent.AbortException(r+" failed");
|
||||
}
|
||||
|
||||
void postExecute(MavenProject project, MojoInfo mojoInfo, Exception exception) throws IOException, InterruptedException, hudson.maven.agent.AbortException {
|
||||
// TODO
|
||||
ModuleName name = new ModuleName(project);
|
||||
MavenBuildProxy2 proxy = buildProxy.get(name);
|
||||
for (MavenReporter r : reporters.get(name))
|
||||
if(!r.postExecute(proxy,project,mojoInfo,listener,exception))
|
||||
throw new hudson.maven.agent.AbortException(r+" failed");
|
||||
if(exception!=null)
|
||||
proxy.setResult(Result.FAILURE);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
Reference in new issue
Block a user