提交 710f168d 编写于 作者: J Jesse Glick

@WithBridgeMethods and @AdaptField did not work to maintain binary compatibility.

Existing code referring to a member of type AbstractBuild often called methods not present in Run.
Changed to retain the existing fields and getters but deprecating them and introducing replacements.
上级 3ddef512
......@@ -1940,7 +1940,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
}
AbstractBuild<?,?> getBuild() {
return (AbstractBuild) e.getParent().getBuild();
return e.getParent().build;
}
}
......
......@@ -23,7 +23,6 @@
*/
package hudson.scm;
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import hudson.model.AbstractBuild;
import hudson.model.TaskAction;
import hudson.model.BuildBadgeAction;
......@@ -36,7 +35,6 @@ import org.kohsuke.stapler.StaplerResponse;
import javax.servlet.ServletException;
import java.io.IOException;
import jenkins.model.RunAction2;
import org.jenkinsci.bytecode.AdaptField;
/**
* Common part of <tt>CVSSCM.TagAction</tt> and <tt>SubversionTagAction</tt>.
......@@ -50,10 +48,13 @@ import org.jenkinsci.bytecode.AdaptField;
*/
public abstract class AbstractScmTagAction extends TaskAction implements BuildBadgeAction, RunAction2 {
private transient /*final*/ Run<?,?> build;
private transient /*final*/ Run<?,?> run;
@Deprecated
protected transient /*final*/ AbstractBuild build;
protected AbstractScmTagAction(Run<?,?> build) {
this.build = build;
protected AbstractScmTagAction(Run<?,?> run) {
this.run = run;
this.build = run instanceof AbstractBuild ? (AbstractBuild) run : null;
}
@Deprecated
......@@ -73,9 +74,12 @@ public abstract class AbstractScmTagAction extends TaskAction implements BuildBa
return SCM.TAG;
}
@AdaptField(name="build", was=AbstractBuild.class)
@WithBridgeMethods(value=AbstractBuild.class, castRequired=true)
public Run getBuild() {
public Run<?,?> getRun() {
return run;
}
@Deprecated
public AbstractBuild getBuild() {
return build;
}
......@@ -92,7 +96,7 @@ public abstract class AbstractScmTagAction extends TaskAction implements BuildBa
public abstract boolean isTagged();
protected ACL getACL() {
return build.getACL();
return run.getACL();
}
public void doIndex(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
......@@ -110,7 +114,8 @@ public abstract class AbstractScmTagAction extends TaskAction implements BuildBa
}
@Override public void onLoad(Run<?, ?> r) {
build = r;
run = r;
build = run instanceof AbstractBuild ? (AbstractBuild) run : null;
}
}
......@@ -58,11 +58,14 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter
/**
* Build whose change log this object represents.
*/
private final Run<?,?> build;
private final Run<?,?> run;
@Deprecated
public final AbstractBuild<?,?> build;
private final RepositoryBrowser</* ideally T */?> browser;
protected ChangeLogSet(Run<?,?> build, RepositoryBrowser<?> browser) {
this.build = build;
protected ChangeLogSet(Run<?,?> run, RepositoryBrowser<?> browser) {
this.run = run;
build = run instanceof AbstractBuild ? (AbstractBuild) run : null;
this.browser = browser;
}
......@@ -77,9 +80,8 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter
return build.getParent().getScm().getEffectiveBrowser();
}
@AdaptField(name="build", was=AbstractBuild.class)
public Run<?,?> getBuild() {
return build;
public Run<?,?> getRun() {
return run;
}
public RepositoryBrowser<?> getBrowser() {
......@@ -238,7 +240,7 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter
MarkupText markup = new MarkupText(getMsg());
for (ChangeLogAnnotator a : ChangeLogAnnotator.all())
try {
a.annotate(parent.build,this,markup);
a.annotate(parent.run, this, markup);
} catch(Exception e) {
LOGGER.info("ChangeLogAnnotator " + a.toString() + " failed to annotate message '" + getMsg() + "'; " + e.getMessage());
} catch(Error e) {
......
......@@ -68,7 +68,6 @@ import jenkins.triggers.SCMTriggerItem;
import net.sf.json.JSONObject;
import org.apache.commons.io.FileUtils;
import org.apache.commons.jelly.XMLOutput;
import org.jenkinsci.bytecode.AdaptField;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.DataBoundConstructor;
......@@ -318,11 +317,13 @@ public class SCMTrigger extends Trigger<Item> {
* @since 1.376
*/
public static class BuildAction implements RunAction2 {
private transient /*final*/ Run<?,?> build;
private transient /*final*/ Run<?,?> run;
@Deprecated
public transient /*final*/ AbstractBuild build;
public BuildAction(Run<?,?> build) {
this.build = build;
public BuildAction(Run<?,?> run) {
this.run = run;
build = run instanceof AbstractBuild ? (AbstractBuild) run : null;
}
@Deprecated
......@@ -330,16 +331,15 @@ public class SCMTrigger extends Trigger<Item> {
this((Run) build);
}
@AdaptField(name="build", was=AbstractBuild.class)
public Run<?,?> getBuild() {
return build;
public Run<?,?> getRun() {
return run;
}
/**
* Polling log that triggered the build.
*/
public File getPollingLogFile() {
return new File(build.getRootDir(),"polling.log");
return new File(run.getRootDir(),"polling.log");
}
public String getIconFileName() {
......@@ -385,7 +385,8 @@ public class SCMTrigger extends Trigger<Item> {
}
@Override public void onLoad(Run<?, ?> r) {
build = r;
run = r;
build = run instanceof AbstractBuild ? (AbstractBuild) run : null;
}
}
......
......@@ -27,8 +27,8 @@ THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<st:compress xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<l:layout title="${it.build.parent.displayName} #${it.build.number} ${%Polling Log}" norefresh="true">
<st:include it="${it.build}" page="sidepanel.jelly" />
<l:layout title="${it.run.parent.displayName} #${it.run.number} ${%Polling Log}" norefresh="true">
<st:include it="${it.run}" page="sidepanel.jelly" />
<l:main-panel>
<h1>${%Polling Log}</h1>
<l:rightspace>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册