@@ -60,7 +60,7 @@ public class MatlabBuilder extends Builder implements SimpleBuildStep {
6060 private static final String MATLAB_RUNNER_RESOURCE =
6161 "com/mathworks/ci/MatlabBuilder/runMatlabTests.m" ;
6262 private static final String AUTOMATIC_OPTION = "RunTestsAutomaticallyOption" ;
63- private String fileSeparator ;
63+ private String nodeSpecificfileSeparator ;
6464
6565
6666 @ DataBoundConstructor
@@ -103,13 +103,6 @@ private void setEnv(EnvVars env) {
103103 this .env = env ;
104104 }
105105
106- private void setFileSeparator (String fileSeparator ) {
107- this .fileSeparator = fileSeparator ;
108- }
109-
110- private String getFileSeparator () {
111- return this .fileSeparator ;
112- }
113106
114107 @ Extension
115108 public static class MatlabDescriptor extends BuildStepDescriptor <Builder > {
@@ -403,8 +396,7 @@ public void perform(@Nonnull Run<?, ?> build, @Nonnull FilePath workspace,
403396 @ Nonnull Launcher launcher , @ Nonnull TaskListener listener )
404397 throws InterruptedException , IOException {
405398 final boolean isLinuxLauncher = launcher .isUnix ();
406- String fileSeparator = getNodeSpecificFileSeperator (launcher );
407- this .setFileSeparator (fileSeparator );
399+ nodeSpecificfileSeparator = getNodeSpecificFileSeperator (launcher );
408400
409401 // Invoke MATLAB command and transfer output to standard
410402 // Output Console
@@ -421,11 +413,11 @@ private synchronized int execMatlabCommand(Run<?, ?> build, FilePath workspace,
421413 throws IOException , InterruptedException {
422414 setEnv (build .getEnvironment (listener ));
423415 final String testRunMode = this .getTestRunTypeList ().getDescriptor ().getId ();
416+ FilePath targetWorkspace = new FilePath (launcher .getChannel (), workspace .getRemote ());
424417
425418 // Copy MATLAB scratch file into the workspace only if Automatic option is selected.
426419 if (testRunMode .contains (AUTOMATIC_OPTION )) {
427- copyMatlabScratchFileInWorkspace (MATLAB_RUNNER_RESOURCE , MATLAB_RUNNER_TARGET_FILE ,
428- workspace , getClass ().getClassLoader (), launcher );
420+ copyMatlabScratchFileInWorkspace (MATLAB_RUNNER_RESOURCE , MATLAB_RUNNER_TARGET_FILE , targetWorkspace );
429421 }
430422 ProcStarter matlabLauncher ;
431423 try {
@@ -462,7 +454,7 @@ public List<String> constructMatlabCommandWithBatch() {
462454 }
463455
464456 matlabDefaultArgs =
465- Arrays .asList (getLocalMatlab () + this . getFileSeparator () + "bin" + this . getFileSeparator () + "matlab" ,
457+ Arrays .asList (getLocalMatlab () + nodeSpecificfileSeparator + "bin" + nodeSpecificfileSeparator + "matlab" ,
466458 "-batch" , runCommand );
467459
468460 return matlabDefaultArgs ;
@@ -485,7 +477,7 @@ public List<String> constructDefaultMatlabCommand(boolean isLinuxLauncher) {
485477
486478 private String [] getPreRunnerSwitches () {
487479 String [] preRunnerSwitches =
488- {getLocalMatlab () + this . getFileSeparator () + "bin" + this . getFileSeparator () + "matlab" , "-nosplash" ,
480+ {getLocalMatlab () + nodeSpecificfileSeparator + "bin" + nodeSpecificfileSeparator + "matlab" , "-nosplash" ,
489481 "-nodesktop" , "-noAppIcon" };
490482 return preRunnerSwitches ;
491483 }
@@ -516,9 +508,9 @@ private String[] getRunnerSwitch() {
516508 }
517509
518510 private void copyMatlabScratchFileInWorkspace (String matlabRunnerResourcePath ,
519- String matlabRunnerTarget , FilePath workspace , ClassLoader classLoader , Launcher launcher )
511+ String matlabRunnerTarget , FilePath targetWorkspace )
520512 throws IOException , InterruptedException {
521- FilePath targetWorkspace = new FilePath ( launcher . getChannel (), workspace . getRemote () );
513+ final ClassLoader classLoader = getClass (). getClassLoader ( );
522514 FilePath targetFile =
523515 new FilePath (targetWorkspace , Message .getValue (matlabRunnerTarget ));
524516 InputStream in = classLoader .getResourceAsStream (matlabRunnerResourcePath );
0 commit comments