diff --git a/core/src/main/java/hudson/model/AbstractBuild.java b/core/src/main/java/hudson/model/AbstractBuild.java index 1860c8c3084e50d3c3a96bae4264710889987c42..3ae603b0cbdc854b40a5a425a43760875676d2e7 100644 --- a/core/src/main/java/hudson/model/AbstractBuild.java +++ b/core/src/main/java/hudson/model/AbstractBuild.java @@ -3,6 +3,7 @@ package hudson.model; import hudson.Launcher; import hudson.Proc.LocalProc; import hudson.Util; +import hudson.tasks.Fingerprinter.FingerprintAction; import hudson.maven.MavenBuild; import static hudson.model.Hudson.isWindows; import hudson.model.listeners.SCMListener; @@ -23,6 +24,7 @@ import java.io.PrintStream; import java.util.Calendar; import java.util.Map; import java.util.HashMap; +import java.util.Collections; /** * Base implementation of {@link Run}s that build software. @@ -287,6 +289,65 @@ public abstract class AbstractBuild

,R extends Abs return r; } + /** + * Gets the changes in the dependency between the given build and this build. + */ + public Map getDependencyChanges(AbstractBuild from) { + if(from==null) return Collections.emptyMap(); // make it easy to call this from views + FingerprintAction n = this.getAction(FingerprintAction.class); + FingerprintAction o = from.getAction(FingerprintAction.class); + if(n==null || o==null) return Collections.emptyMap(); + + Map ndep = n.getDependencies(); + Map odep = o.getDependencies(); + + Map r = new HashMap(); + + for (Map.Entry entry : odep.entrySet()) { + AbstractProject p = entry.getKey(); + Integer oldNumber = entry.getValue(); + Integer newNumber = ndep.get(p); + if(newNumber!=null && oldNumber.compareTo(newNumber)<0) { + r.put(p,new DependencyChange(p,oldNumber,newNumber)); + } + } + + return r; + } + + /** + * Represents a change in the dependency. + */ + public static final class DependencyChange { + /** + * The dependency project. + */ + public final AbstractProject project; + /** + * Version of the dependency project used in the previous build. + */ + public final int fromId; + /** + * {@link Build} object for {@link #fromId}. Can be null if the log is gone. + */ + public final AbstractBuild from; + /** + * Version of the dependency project used in this build. + */ + public final int toId; + + public final AbstractBuild to; + + public DependencyChange(AbstractProject project, int fromId, int toId) { + this.project = project; + this.fromId = fromId; + this.toId = toId; + this.from = project.getBuildByNumber(fromId); + this.to = project.getBuildByNumber(toId); + } + } + + // // // web methods diff --git a/core/src/main/java/hudson/model/Build.java b/core/src/main/java/hudson/model/Build.java index 9126d4d37950f42dd743995f757a09273832f696..c1de26296c8dfda08b038794e1dc77d49a2553a4 100644 --- a/core/src/main/java/hudson/model/Build.java +++ b/core/src/main/java/hudson/model/Build.java @@ -15,8 +15,6 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Calendar; -import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -86,64 +84,6 @@ public final class Build extends AbstractBuild { return n; } - /** - * Gets the changes in the dependency between the given build and this build. - */ - public Map getDependencyChanges(Build from) { - if(from==null) return Collections.emptyMap(); // make it easy to call this from views - FingerprintAction n = this.getAction(FingerprintAction.class); - FingerprintAction o = from.getAction(FingerprintAction.class); - if(n==null || o==null) return Collections.emptyMap(); - - Map ndep = n.getDependencies(); - Map odep = o.getDependencies(); - - Map r = new HashMap(); - - for (Map.Entry entry : odep.entrySet()) { - Project p = entry.getKey(); - Integer oldNumber = entry.getValue(); - Integer newNumber = ndep.get(p); - if(newNumber!=null && oldNumber.compareTo(newNumber)<0) { - r.put(p,new DependencyChange(p,oldNumber,newNumber)); - } - } - - return r; - } - - /** - * Represents a change in the dependency. - */ - public static final class DependencyChange { - /** - * The dependency project. - */ - public final Project project; - /** - * Version of the dependency project used in the previous build. - */ - public final int fromId; - /** - * {@link Build} object for {@link #fromId}. Can be null if the log is gone. - */ - public final Build from; - /** - * Version of the dependency project used in this build. - */ - public final int toId; - - public final Build to; - - public DependencyChange(Project project, int fromId, int toId) { - this.project = project; - this.fromId = fromId; - this.toId = toId; - this.from = project.getBuildByNumber(fromId); - this.to = project.getBuildByNumber(toId); - } - } - /** * During the build this field remembers {@link Environment}s created by * {@link BuildWrapper}. This design is bit ugly but forced due to compatibility.