Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit f78f07a

Browse files
Fix matlab batch path bug (#391)
* install matlab-batch to MATLAB_HOME/bin as workaround for node paths * remove unused getNthParent method
1 parent bc36eed commit f78f07a

File tree

5 files changed

+9
-44
lines changed

5 files changed

+9
-44
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</parent>
1212

1313
<artifactId>matlab</artifactId>
14-
<version>2.15.1-SNAPSHOT</version>
14+
<version>2.16.0-SNAPSHOT</version>
1515
<packaging>hpi</packaging>
1616

1717
<name>MATLAB Plugin</name>
@@ -286,4 +286,4 @@
286286
</plugins>
287287
</pluginManagement>
288288
</build>
289-
</project>
289+
</project>

src/main/java/com/mathworks/ci/MatlabInstallation.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,7 @@ public void buildEnvVars(EnvVars env) {
6464
if (home == null) {
6565
return;
6666
}
67-
FilePath matlabHome = new FilePath(new File(home));
68-
FilePath matlabBin = new FilePath(matlabHome, "bin");
69-
env.put("PATH+matlabroot", matlabBin.getRemote());
70-
FilePath matlabBatchFolder = matlabHome.getParent();
71-
if (matlabBatchFolder != null) {
72-
env.put("PATH+matlabbatch", matlabBatchFolder.getRemote());
73-
}
67+
env.put("PATH+matlabroot", home + "/bin");
7468
}
7569

7670
public static MatlabInstallation[] getAll() {

src/main/java/com/mathworks/ci/UseMatlabVersionBuildWrapper.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,6 @@ public void setUp(Context context, Run<?, ?> build, FilePath workspace, Launcher
201201
if (matlabBinDir == null) {
202202
throw new MatlabNotFoundError(Message.getValue("matlab.not.found.error"));
203203
}
204-
// Add matlab-batch executable in path
205-
FilePath batchExecutable = getNthParentFilePath(matlabExecutablePath, 3);
206-
if (batchExecutable != null && batchExecutable.exists()) {
207-
context.env("PATH+matlabbatch", batchExecutable.getRemote());
208-
}
209204

210205
// Add "matlabroot" without bin as env variable which will be available across
211206
// the build.
@@ -221,19 +216,4 @@ private String getNodeSpecificExecutable(Launcher launcher) {
221216
return (launcher.isUnix()) ? "/bin/matlab" : "\\bin\\matlab.exe";
222217
}
223218

224-
public static FilePath getNthParentFilePath(FilePath path, int levels) {
225-
if (path == null || levels < 0) {
226-
return null;
227-
}
228-
229-
FilePath currentPath = path;
230-
for (int i = 0; i < levels; i++) {
231-
if (currentPath == null) {
232-
return null;
233-
}
234-
currentPath = currentPath.getParent();
235-
}
236-
return currentPath;
237-
}
238-
239219
}

src/main/java/com/mathworks/ci/Utilities.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,14 @@ public static void addMatlabToEnvPathFromAxis(Computer cmp, TaskListener listene
4040
return;
4141
}
4242

43-
FilePath matlabRoot = getNodeSpecificHome(name,
44-
cmp.getNode(), listener, env);
43+
FilePath matlabRoot = getNodeSpecificHome(name, cmp.getNode(), listener, env);
4544

46-
FilePath toolHome = matlabRoot.getParent();
47-
if (toolHome == null) {
48-
return;
49-
}
50-
if (matlabRoot != null && toolHome.exists()) {
51-
env.put("PATH+matlabbatch", toolHome.getRemote());
52-
}
53-
54-
String matlabExecutablePath = getNodeSpecificHome(name,
55-
cmp.getNode(), listener, env).getRemote() + ((Boolean.TRUE.equals(cmp.isUnix())) ? "/bin" : "\\bin");
56-
env.put("PATH+matlabroot", matlabExecutablePath);
45+
FilePath matlabBin = new FilePath(matlabRoot, "bin");
46+
env.put("PATH+matlabroot", matlabBin.getRemote());
5747

5848
// Specify which MATLAB was added to path.
5949
listener.getLogger().println(
60-
"\n" + String.format(Message.getValue("matlab.added.to.path.from"), matlabExecutablePath) + "\n");
50+
"\n" + String.format(Message.getValue("matlab.added.to.path.from"), matlabBin.getRemote()) + "\n");
6151
}
6252

6353
public static FilePath getNodeSpecificHome(String instName, Node node, TaskListener listener, EnvVars env)

src/main/java/com/mathworks/ci/tools/MatlabInstaller.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ public FilePath performInstallation(ToolInstallation tool, Node node, TaskListen
9696
mpmInstall(mpm, this.getRelease(), this.getProducts(), matlabRoot, node, log);
9797

9898
// Copy downloaded matlab-batch to tool directory
99-
matlabBatch.copyTo(new FilePath(toolRoot, "matlab-batch" + extension));
99+
FilePath matlabBin = new FilePath(matlabRoot, "bin");
100+
matlabBatch.copyTo(new FilePath(matlabBin, "matlab-batch" + extension));
100101

101102
// Delete temp directory
102103
tempDir.deleteRecursive();

0 commit comments

Comments
 (0)