@@ -55,7 +55,6 @@ public class MatlabBuilder extends Builder implements SimpleBuildStep {
5555 private TestRunTypeList testRunTypeList ;
5656 private String matlabRoot ;
5757 private EnvVars env ;
58- private FilePath workspace ;
5958 private static final String MATLAB_RUNNER_TARGET_FILE =
6059 "Builder.matlab.runner.target.file.name" ;
6160 private static final String MATLAB_RUNNER_RESOURCE =
@@ -101,9 +100,6 @@ private String getCustomMatlabCommand() {
101100 private void setEnv (EnvVars env ) {
102101 this .env = env ;
103102 }
104- private void setWorkspace (FilePath workspace ) {
105- this .workspace = workspace ;
106- }
107103
108104 @ Extension
109105 public static class MatlabDescriptor extends BuildStepDescriptor <Builder > {
@@ -412,7 +408,14 @@ private synchronized int execMatlabCommand(Run<?, ?> build, FilePath workspace,
412408 TaskListener listener , boolean isLinuxLauncher )
413409 throws IOException , InterruptedException {
414410 setEnv (build .getEnvironment (listener ));
415- setWorkspace (workspace );
411+ final String testRunMode = this .getTestRunTypeList ().getDescriptor ().getDisplayName ();
412+
413+ // Copy MATLAB scratch file into the workspace only if Automatic option is selected.
414+ if (!testRunMode .equalsIgnoreCase (
415+ Message .getValue ("builder.matlab.customcommandoption.display.name" ))) {
416+ copyMatlabScratchFileInWorkspace (MATLAB_RUNNER_RESOURCE , MATLAB_RUNNER_TARGET_FILE ,
417+ workspace , getClass ().getClassLoader ());
418+ }
416419 ProcStarter matlabLauncher ;
417420 try {
418421 MatlabReleaseInfo rel = new MatlabReleaseInfo (getLocalMatlab ());
@@ -430,16 +433,12 @@ private synchronized int execMatlabCommand(Run<?, ?> build, FilePath workspace,
430433 return matlabLauncher .join ();
431434 }
432435
433- public List <String > constructMatlabCommandWithBatch () throws IOException , InterruptedException {
436+ public List <String > constructMatlabCommandWithBatch () {
434437 final String testRunMode = this .getTestRunTypeList ().getDescriptor ().getDisplayName ();
435438 final String runCommand ;
436439 final List <String > matlabDefaultArgs ;
437440 if (!testRunMode .equalsIgnoreCase (
438441 Message .getValue ("builder.matlab.customcommandoption.display.name" ))) {
439-
440- //Copy MATLAB scratch file into the workspace only if Automatic option is selected.
441- copyMatlabScratchFileInWorkspace (MATLAB_RUNNER_RESOURCE , MATLAB_RUNNER_TARGET_FILE ,
442- this .workspace , getClass ().getClassLoader ());
443442 String matlabFunctionName =
444443 FilenameUtils .removeExtension (Message .getValue (MATLAB_RUNNER_TARGET_FILE ));
445444 runCommand = "exit(" + matlabFunctionName + "("
@@ -458,7 +457,7 @@ public List<String> constructMatlabCommandWithBatch() throws IOException, Interr
458457 return matlabDefaultArgs ;
459458 }
460459
461- public List <String > constructDefaultMatlabCommand (boolean isLinuxLauncher ) throws IOException , InterruptedException {
460+ public List <String > constructDefaultMatlabCommand (boolean isLinuxLauncher ) {
462461 final List <String > matlabDefaultArgs = new ArrayList <String >();
463462 Collections .addAll (matlabDefaultArgs , getPreRunnerSwitches ());
464463 if (!isLinuxLauncher ) {
@@ -485,15 +484,11 @@ private String[] getPostRunnerSwitches() {
485484 return postRunnerSwitch ;
486485 }
487486
488- private String [] getRunnerSwitch () throws IOException , InterruptedException {
487+ private String [] getRunnerSwitch () {
489488 final String runCommand ;
490489 final String testRunMode = this .getTestRunTypeList ().getDescriptor ().getDisplayName ();
491490 if (!testRunMode .equalsIgnoreCase (
492491 Message .getValue ("builder.matlab.customcommandoption.display.name" ))) {
493-
494- //Copy MATLAB scratch file into the workspace only if Automatic option is selected.
495- copyMatlabScratchFileInWorkspace (MATLAB_RUNNER_RESOURCE , MATLAB_RUNNER_TARGET_FILE ,
496- this .workspace , getClass ().getClassLoader ());
497492 String matlabFunctionName =
498493 FilenameUtils .removeExtension (Message .getValue (MATLAB_RUNNER_TARGET_FILE ));
499494 runCommand = "try,exit(" + matlabFunctionName + "("
0 commit comments