Package com.mathworks.ci.utilities
Class MatlabCommandRunner
java.lang.Object
com.mathworks.ci.utilities.MatlabCommandRunner
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEnvironmentVariable(String key, String value) Adds an environment variable.copyFileToTempFolder(String sourceFile, String targetFile) Copies a resource into the temporary folder.protected FilePathcreateFileWithContent(String content) Creates a file with the specified content in the temporary folder.protected FilePathCopies platform specific runner file into the temporary folder.voidRedirects stdout.voidvoidrunMatlabCommand(String command) Spawns a process to run the specified command.
-
Constructor Details
-
MatlabCommandRunner
- Throws:
IOExceptionInterruptedException
-
-
Method Details
-
runMatlabCommand
public void runMatlabCommand(String command) throws IOException, InterruptedException, MatlabExecutionException Spawns a process to run the specified command.- Parameters:
command- The command to run- Throws:
IOExceptionInterruptedExceptionMatlabExecutionException
-
redirectStdOut
Redirects stdout.- Parameters:
out- the OutputStream to write to
-
addEnvironmentVariable
Adds an environment variable.- Parameters:
key- the environment variable namevalue- the environment variable value
-
getEnvVars
-
copyFileToTempFolder
public FilePath copyFileToTempFolder(String sourceFile, String targetFile) throws IOException, InterruptedException Copies a resource into the temporary folder.- Parameters:
sourceFile- the name of a resource the class loader can find.targetFile- the name of the file to create in the temp folder.- Returns:
- the FilePath to the new location in the temp folder.
- Throws:
IOExceptionInterruptedException
-
getTempFolder
-
removeTempFolder
- Throws:
IOExceptionInterruptedException
-
createFileWithContent
Creates a file with the specified content in the temporary folder. Additionally, the file content will be prefixed with a statement returning to the MATLAB starting folder.- Parameters:
content- string that represents the content of the file.- Returns:
- the FilePath to the script file that is created.
- Throws:
IOExceptionInterruptedException
-
prepareRunnerExecutable
Copies platform specific runner file into the temporary folder.- Returns:
- the FilePath to the runner executable
- Throws:
IOExceptionInterruptedException
-