Package com.mathworks.ci.utilities
Class MatlabCommandRunner
java.lang.Object
com.mathworks.ci.utilities.MatlabCommandRunner
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEnvironmentVariable
(String key, String value) Adds an environment variable.copyFileToTempFolder
(String sourceFile, String targetFile) Copies a resource into the temporary folder.protected FilePath
createFileWithContent
(String content) Creates a file with the specified content in the temporary folder.protected FilePath
Copies platform specific runner file into the temporary folder.void
Redirects stdout.void
void
runMatlabCommand
(String command) Spawns a process to run the specified command.
-
Constructor Details
-
MatlabCommandRunner
- Throws:
IOException
InterruptedException
-
-
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:
IOException
InterruptedException
MatlabExecutionException
-
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:
IOException
InterruptedException
-
getTempFolder
-
removeTempFolder
- Throws:
IOException
InterruptedException
-
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:
IOException
InterruptedException
-
prepareRunnerExecutable
Copies platform specific runner file into the temporary folder.- Returns:
- the FilePath to the runner executable
- Throws:
IOException
InterruptedException
-