@@ -85,23 +85,27 @@ default String getUniqueNameForRunnerFile() {
8585
8686 // This method prepares the temp folder by coping all helper files in it.
8787 default void prepareTmpFldr (FilePath tmpFldr , String runnerScript ) throws IOException , InterruptedException {
88- // Write MATLAB scratch file in temp folder.
89- FilePath scriptFile =
90- new FilePath (tmpFldr , getValidMatlabFileName (tmpFldr .getBaseName ()) + ".m" );
91- scriptFile .write (runnerScript , "UTF-8" );
9288 // copy genscript package
9389 copyFileInWorkspace (MatlabBuilderConstants .MATLAB_SCRIPT_GENERATOR ,
9490 MatlabBuilderConstants .MATLAB_SCRIPT_GENERATOR , tmpFldr );
9591 FilePath zipFileLocation =
9692 new FilePath (tmpFldr , MatlabBuilderConstants .MATLAB_SCRIPT_GENERATOR );
93+ runnerScript =replaceZipPlaceholder (runnerScript , zipFileLocation .getRemote ());
9794
98- // Unzip the file in temp folder.
99- zipFileLocation .unzip (tmpFldr );
95+ // Write MATLAB scratch file in temp folder.
96+ FilePath scriptFile =
97+ new FilePath (tmpFldr , getValidMatlabFileName (tmpFldr .getBaseName ()) + ".m" );
98+ scriptFile .write (runnerScript , "UTF-8" );
99+ }
100+
101+ //This method replaces the placeholder with genscript's zip file location URL in temp folder
102+ default String replaceZipPlaceholder (String script , String url ) {
103+ script = script .replace ("${ZIP_FILE}" , url .replaceAll ("'" ,"''" ));
104+ return script ;
100105 }
101106
102107 default String getRunnerScript (String script , String params , String uniqueTmpFldrName ) {
103108 script = script .replace ("${PARAMS}" , params );
104- script = script .replaceAll ("\\ $\\ {TMPDIR\\ }" , uniqueTmpFldrName );
105109 return script ;
106110 }
107111
0 commit comments