diff --git a/core/src/main/java/hudson/matrix/MatrixBuild.java b/core/src/main/java/hudson/matrix/MatrixBuild.java index fe40953123334bc7d7622c8fe2cf593ae271548e..4c46bb05aad6a1dff146c6c76b05f95ceaa7dfce 100644 --- a/core/src/main/java/hudson/matrix/MatrixBuild.java +++ b/core/src/main/java/hudson/matrix/MatrixBuild.java @@ -273,7 +273,7 @@ public class MatrixBuild extends AbstractBuild { @Override public void run() { - run(new RunnerImpl()); + execute(new MatrixBuildExecution()); } @Override @@ -284,7 +284,7 @@ public class MatrixBuild extends AbstractBuild { return rs; } - private class RunnerImpl extends AbstractRunner { + private class MatrixBuildExecution extends AbstractBuildExecution { private final List aggregators = new ArrayList(); protected Result doRun(BuildListener listener) throws Exception { diff --git a/core/src/main/java/hudson/matrix/MatrixProject.java b/core/src/main/java/hudson/matrix/MatrixProject.java index 8a45c3b1dc133b8d1cf0826f13d3e8c347255ec2..70c21bd97599d44e3ed167a69f8b01572fa612a0 100644 --- a/core/src/main/java/hudson/matrix/MatrixProject.java +++ b/core/src/main/java/hudson/matrix/MatrixProject.java @@ -58,8 +58,6 @@ import hudson.util.CopyOnWriteMap; import hudson.util.DescribableList; import hudson.util.FormValidation; import hudson.util.FormValidation.Kind; -import jenkins.scm.DefaultSCMCheckoutStrategyImpl; -import jenkins.scm.SCMCheckoutStrategy; import jenkins.scm.SCMCheckoutStrategyDescriptor; import net.sf.json.JSONObject; import org.kohsuke.stapler.HttpResponse; @@ -188,7 +186,7 @@ public class MatrixProject extends AbstractProject im /** * Gets the workspace location that {@link MatrixConfiguration} uses. * - * @see MatrixRun.RunnerImpl#decideWorkspace(Node, WorkspaceList) + * @see MatrixRun.MatrixRunExecution#decideWorkspace(Node, WorkspaceList) * * @return never null * even when {@link MatrixProject} uses no custom workspace, this method still diff --git a/core/src/main/java/hudson/matrix/MatrixRun.java b/core/src/main/java/hudson/matrix/MatrixRun.java index 0f56d9d13f54c1414030104ff230b0b4a52dd76d..9e283a756643c89514d9ac41ca43d8d241b6b329 100644 --- a/core/src/main/java/hudson/matrix/MatrixRun.java +++ b/core/src/main/java/hudson/matrix/MatrixRun.java @@ -143,10 +143,10 @@ public class MatrixRun extends Build { @Override public void run() { - run(new RunnerImpl()); + execute(new MatrixRunExecution()); } - private class RunnerImpl extends Build.RunnerImpl { + private class MatrixRunExecution extends BuildExecution { protected Lease getParentWorkspaceLease(Node n, WorkspaceList wsl) throws InterruptedException, IOException { MatrixProject mp = getParent().getParent(); diff --git a/core/src/main/java/hudson/model/AbstractBuild.java b/core/src/main/java/hudson/model/AbstractBuild.java index 4066d1fa44adf2b4f3704943beb384989830ae12..2703d8d7f3163cb447de988f818cf792370d13fc 100644 --- a/core/src/main/java/hudson/model/AbstractBuild.java +++ b/core/src/main/java/hudson/model/AbstractBuild.java @@ -241,7 +241,7 @@ public abstract class AbstractBuild

,R extends Abs * *

* Note to implementors: to control where the workspace is created, override - * {@link AbstractRunner#decideWorkspace(Node,WorkspaceList)}. + * {@link AbstractBuildExecution#decideWorkspace(Node,WorkspaceList)}. * * @return * null if the workspace is on a slave that's not connected. Note that once the build is completed, @@ -257,7 +257,7 @@ public abstract class AbstractBuild

,R extends Abs } /** - * Normally, a workspace is assigned by {@link Runner}, but this lets you set the workspace in case + * Normally, a workspace is assigned by {@link RunExecution}, but this lets you set the workspace in case * {@link AbstractBuild} is created without a build. */ protected void setWorkspace(FilePath ws) { @@ -407,7 +407,20 @@ public abstract class AbstractBuild

,R extends Abs Util.createSymlink(getProject().getBuildDir(),"builds/"+getId(),"../"+name,listener); } - public abstract class AbstractRunner extends Runner { + /** + * @deprecated as of 1.467 + * Please use {@link RunExecution} + */ + public abstract class AbstractRunner extends AbstractBuildExecution { + + } + + public abstract class AbstractBuildExecution extends Runner { + /* + Some plugins might depend on this instance castable to Runner, so we need to use + deprecated class here. + */ + /** * Since configuration can be changed while a build is in progress, * create a launcher once and stick to it for the entire build duration. diff --git a/core/src/main/java/hudson/model/Build.java b/core/src/main/java/hudson/model/Build.java index 90bc24cd92d180cf7e82c18c732021b887f90736..aa27a71580d02c56ee7351f37500f3a45679535f 100644 --- a/core/src/main/java/hudson/model/Build.java +++ b/core/src/main/java/hudson/model/Build.java @@ -23,11 +23,14 @@ */ package hudson.model; +import hudson.Launcher; import hudson.tasks.BuildStep; import hudson.tasks.BuildWrapper; import hudson.tasks.Builder; import hudson.tasks.Recorder; import hudson.tasks.Notifier; +import org.kohsuke.accmod.Restricted; +import org.kohsuke.accmod.restrictions.NoExternalUse; import java.io.File; import java.io.IOException; @@ -107,14 +110,32 @@ public abstract class Build

,B extends Build> // @Override public void run() { - run(createRunner()); + execute(createRunner()); } + /** + * @deprecated as of 1.467 + * Override the {@link #run()} method by calling {@link #execute(RunExecution)} with + * proper execution object. + */ + @Restricted(NoExternalUse.class) protected Runner createRunner() { - return new RunnerImpl(); + return new BuildExecution(); + } + + /** + * @deprecated as of 1.467 + * Please use {@link BuildExecution} + */ + protected class RunnerImpl extends BuildExecution { } - - protected class RunnerImpl extends AbstractRunner { + + protected class BuildExecution extends AbstractRunner { + /* + Some plugins might depend on this instance castable to Runner, so we need to use + deprecated class here. + */ + protected Result doRun(BuildListener listener) throws Exception { if(!preBuild(listener,project.getBuilders())) return FAILURE; diff --git a/core/src/main/java/hudson/model/ExternalRun.java b/core/src/main/java/hudson/model/ExternalRun.java index 2433f01f05d111d8a1fcd1a8252be656c8f14df0..b55fdfd2d722d07c4dd56766c4ef9b0d60bd9478 100644 --- a/core/src/main/java/hudson/model/ExternalRun.java +++ b/core/src/main/java/hudson/model/ExternalRun.java @@ -63,7 +63,7 @@ public class ExternalRun extends Run { * record the log and its exit code, then call it a build. */ public void run(final String[] cmd) { - run(new Runner() { + execute(new RunExecution() { public Result run(BuildListener listener) throws Exception { Proc proc = new Proc.LocalProc(cmd,getEnvironment(listener),System.in,new DualOutputStream(System.out,listener.getLogger())); return proc.join()==0?Result.SUCCESS:Result.FAILURE; @@ -97,7 +97,7 @@ public class ExternalRun extends Run { @IgnoreJRERequirement public void acceptRemoteSubmission(final Reader in) throws IOException { final long[] duration = new long[1]; - run(new Runner() { + execute(new RunExecution() { private String elementText(XMLStreamReader r) throws XMLStreamException { StringBuilder buf = new StringBuilder(); while(true) { diff --git a/core/src/main/java/hudson/model/FreeStyleBuild.java b/core/src/main/java/hudson/model/FreeStyleBuild.java index 896274add934e1d9ada7fbecc641b1367d899f30..df091cd142b80d0cddf4e71b10560658dc64ba2a 100644 --- a/core/src/main/java/hudson/model/FreeStyleBuild.java +++ b/core/src/main/java/hudson/model/FreeStyleBuild.java @@ -43,6 +43,6 @@ public class FreeStyleBuild extends Build { @Override public void run() { - run(new RunnerImpl()); + execute(new BuildExecution()); } } diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index 7200966ddf0133d383afe0dbccd1917bf5ab4125..62bb904a17170e41812802b0583403ed535f043a 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -238,10 +238,10 @@ public abstract class Run ,RunT extends Run ID_FORMATTER = new ThreadLocal() { @@ -1282,7 +1282,7 @@ public abstract class Run ,RunT extends Run,RunT extends Run checkpoints = new HashSet(); @@ -1376,7 +1386,7 @@ public abstract class Run ,RunT extends Run,RunT extends Run> stack = new WeakHashMap>(); + private final Map> stack = new WeakHashMap>(); - synchronized void push(Runner r) { + synchronized void push(RunExecution r) { Executor e = Executor.currentExecutor(); - Stack s = stack.get(e); - if(s==null) stack.put(e,s=new Stack()); + Stack s = stack.get(e); + if(s==null) stack.put(e,s=new Stack()); s.push(r); } synchronized void pop() { Executor e = Executor.currentExecutor(); - Stack s = stack.get(e); + Stack s = stack.get(e); s.pop(); if(s.isEmpty()) stack.remove(e); } - synchronized Runner peek() { + synchronized RunExecution peek() { return stack.get(Executor.currentExecutor()).peek(); } diff --git a/core/src/main/java/jenkins/scm/SCMCheckoutStrategy.java b/core/src/main/java/jenkins/scm/SCMCheckoutStrategy.java index 0c0d654e25c248b2138af6c6d863fa0991fb5af5..ca5d07b503eb97475a5feca4ce9194fb9f4d30b6 100644 --- a/core/src/main/java/jenkins/scm/SCMCheckoutStrategy.java +++ b/core/src/main/java/jenkins/scm/SCMCheckoutStrategy.java @@ -5,6 +5,7 @@ import hudson.Launcher; import hudson.matrix.MatrixBuild; import hudson.matrix.MatrixRun; import hudson.model.AbstractBuild; +import hudson.model.AbstractBuild.AbstractBuildExecution; import hudson.model.AbstractDescribableImpl; import hudson.model.AbstractProject; import hudson.model.BuildListener; @@ -83,8 +84,8 @@ public abstract class SCMCheckoutStrategy extends AbstractDescribableImpl { @Override public void run() { - run(new RunnerImpl()); + execute(new MavenBuildExecution()); getProject().updateTransientActions(); @@ -543,7 +542,7 @@ public class MavenBuild extends AbstractMavenBuild { // failed before it didn't even get to this module // OR if the aggregated build is an incremental one and this // module needn't be build. - run(new Runner() { + MavenBuild.this.execute(new RunExecution() { public Result run(BuildListener listener) { listener.getLogger().println(Messages.MavenBuild_FailedEarlier()); return Result.NOT_BUILT; @@ -642,7 +641,7 @@ public class MavenBuild extends AbstractMavenBuild { - private class RunnerImpl extends AbstractRunner { + private class MavenBuildExecution extends AbstractBuildExecution { private List reporters; @Override diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index aa67b61d7e41953e358037de6f6f094c9484a62a..6896e8c4a0f8fadaf28562d0858eba1d104dbaff 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -474,7 +474,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild proxies; protected Result doRun(final BuildListener listener) throws Exception {