@@ -118,23 +118,13 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
118118 final String uniqueTmpFldrName = getUniqueNameForRunnerFile ();
119119 final String uniqueCommandFile =
120120 "command_" + getUniqueNameForRunnerFile ().replaceAll ("-" , "_" );
121-
122- // Get unique temporary folder filepath
123121 final FilePath uniqeTmpFolderPath =
124122 getFilePathForUniqueFolder (launcher , uniqueTmpFldrName , workspace );
125- // Create a new command runner script in the temp folder.
126- final FilePath matlabCommandFile =
127- new FilePath (uniqeTmpFolderPath , uniqueCommandFile + ".m" );
128- final String matlabCommandFileContent =
129- "cd '" + workspace .getRemote ().replaceAll ("'" , "''" ) + "';\n " + getCommand ();
130-
131- // Display the commands on console output for users reference
132- listener .getLogger ()
133- .println ("Generating MATLAB script with content:\n " + getCommand () + "\n " );
123+
124+ // Create MATLAB script
125+ createMatlabScriptByName (uniqeTmpFolderPath ,uniqueCommandFile ,workspace ,listener );
134126
135- matlabCommandFile .write (matlabCommandFileContent , "UTF-8" );
136127 try {
137- launcher = getDecoratedLauncherForWindows (launcher );
138128 // Start the launcher from temp folder
139129 ProcStarter matlabLauncher = launcher .launch ().pwd (uniqeTmpFolderPath ).envs (envVars );
140130 listener .getLogger ()
@@ -152,4 +142,19 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
152142 }
153143 }
154144 }
145+
146+ private void createMatlabScriptByName (FilePath uniqeTmpFolderPath , String uniqueScriptName , FilePath workspace , TaskListener listener ) throws IOException , InterruptedException {
147+
148+ // Create a new command runner script in the temp folder.
149+ final FilePath matlabCommandFile =
150+ new FilePath (uniqeTmpFolderPath , uniqueScriptName + ".m" );
151+ final String matlabCommandFileContent =
152+ "cd '" + workspace .getRemote ().replaceAll ("'" , "''" ) + "';\n " + getCommand ();
153+
154+ // Display the commands on console output for users reference
155+ listener .getLogger ()
156+ .println ("Generating MATLAB script with content:\n " + getCommand () + "\n " );
157+
158+ matlabCommandFile .write (matlabCommandFileContent , "UTF-8" );
159+ }
155160}
0 commit comments