提交 f1d75075 编写于 作者: K kohsuke

modified to align build numbers among modules.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@2004 71c3de6d-444a-0410-be80-ed276b4c234a
上级 b2199a6f
......@@ -102,6 +102,17 @@ public final class MavenModule extends AbstractProject<MavenModule,MavenBuild> i
return (MavenModuleSet)super.getParent();
}
/*package*/ int peekNextBuildNumber() {
return nextBuildNumber;
}
/*package*/ void updateNextBuildNumber(int next) throws IOException {
if(next>nextBuildNumber) {
this.nextBuildNumber = next;
saveNextBuildNumber();
}
}
/**
* {@link MavenModule} uses the workspace of the {@link MavenModuleSet},
* so it always needs to be built on the same slave as the parent.
......
......@@ -2,6 +2,7 @@ package hudson.maven;
import hudson.FilePath;
import hudson.Launcher;
import hudson.triggers.Trigger;
import hudson.model.AbstractProject;
import hudson.model.DependencyGraph;
import hudson.model.Hudson;
......@@ -12,6 +13,7 @@ import hudson.model.Job;
import hudson.model.TaskListener;
import hudson.model.TopLevelItem;
import hudson.model.TopLevelItemDescriptor;
import hudson.model.Executor;
import hudson.util.CopyOnWriteMap;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
......@@ -151,6 +153,33 @@ public class MavenModuleSet extends AbstractProject<MavenModuleSet,MavenModuleSe
}
}
/**
* To make it easy to grasp relationship among modules
* and the module set, we'll align the build numbers of
* all the modules.
*
* <p>
* This method is invoked from {@link Executor#run()},
* and because of the mutual exclusion among {@link MavenModuleSetBuild}
* and {@link MavenBuild}, we can safely touch all the modules.
*/
public synchronized int assignBuildNumber() throws IOException {
// determine the next value
int next = this.nextBuildNumber;
for (MavenModule m : modules.values())
next = Math.max(next,m.peekNextBuildNumber());
if(this.nextBuildNumber!=next) {
this.nextBuildNumber=next;
this.saveNextBuildNumber();
}
for (MavenModule m : modules.values())
m.updateNextBuildNumber(next);
return super.assignBuildNumber();
}
protected void buildDependencyGraph(DependencyGraph graph) {
// no dependency for this.
}
......
......@@ -110,7 +110,7 @@ public abstract class Job<JobT extends Job<JobT,RunT>, RunT extends Run<JobT,Run
return new TextFile(new File(this.getRootDir(),"nextBuildNumber"));
}
private void saveNextBuildNumber() throws IOException {
protected void saveNextBuildNumber() throws IOException {
getNextBuildNumberFile().write(String.valueOf(nextBuildNumber)+'\n');
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册