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