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

Commit 7afc938

Browse files
resolve latest release and use that to name folder. also revert pom version bump (#393)
1 parent 7eddec2 commit 7afc938

File tree

3 files changed

+40
-24
lines changed

3 files changed

+40
-24
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</parent>
1212

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

1717
<name>MATLAB Plugin</name>

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

+24-23
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.mathworks.ci.tools;
22

33
/**
4-
* Copyright 2024, The MathWorks, Inc.
4+
* Copyright 2024-2025, The MathWorks, Inc.
55
*/
66

77
import com.mathworks.ci.MatlabInstallation;
@@ -49,7 +49,7 @@ public MatlabInstaller(String id) {
4949
}
5050

5151
public String getRelease() {
52-
return this.release.trim();
52+
return this.release;
5353
}
5454

5555
@DataBoundSetter
@@ -75,10 +75,12 @@ public FilePath performInstallation(ToolInstallation tool, Node node, TaskListen
7575
String extension = "";
7676
String[] systemProperties = getSystemProperties(node);
7777
FilePath matlabRoot;
78+
MatlabRelease release = parseRelease(this.getRelease());
79+
7880
if (systemProperties[0].toLowerCase().contains("os x")) {
79-
matlabRoot = new FilePath(toolRoot, this.getRelease() + ".app");
81+
matlabRoot = new FilePath(toolRoot, release.name + ".app");
8082
} else {
81-
matlabRoot = new FilePath(toolRoot, this.getRelease());
83+
matlabRoot = new FilePath(toolRoot, release.name);
8284
}
8385
String platform = getPlatform(systemProperties[0], systemProperties[1]);
8486
if (platform == "win64") {
@@ -93,7 +95,7 @@ public FilePath performInstallation(ToolInstallation tool, Node node, TaskListen
9395
FilePath matlabBatch = fetchMatlabBatch(platform, tempDir);
9496

9597
// Install with mpm
96-
mpmInstall(mpm, this.getRelease(), this.getProducts(), matlabRoot, node, log);
98+
mpmInstall(mpm, release, this.getProducts(), matlabRoot, node, log);
9799

98100
// Copy downloaded matlab-batch to tool directory
99101
FilePath matlabBin = new FilePath(matlabRoot, "bin");
@@ -105,7 +107,7 @@ public FilePath performInstallation(ToolInstallation tool, Node node, TaskListen
105107
return matlabRoot;
106108
}
107109

108-
private void mpmInstall(FilePath mpmPath, String release, String products, FilePath destination, Node node,
110+
private void mpmInstall(FilePath mpmPath, MatlabRelease release, String products, FilePath destination, Node node,
109111
TaskListener log)
110112
throws IOException, InterruptedException {
111113
makeDir(destination);
@@ -115,7 +117,10 @@ private void mpmInstall(FilePath mpmPath, String release, String products, FileP
115117
ArgumentListBuilder args = new ArgumentListBuilder();
116118
args.add(mpmPath.getRemote());
117119
args.add("install");
118-
appendReleaseToArguments(release, args, log);
120+
args.add("--release=" + release.name);
121+
if (release.isPrerelease) {
122+
args.add("--release-status=Prerelease");
123+
}
119124
args.add("--destination=" + destination.getRemote());
120125
addMatlabProductsToArgs(args, products);
121126

@@ -145,29 +150,25 @@ private void makeDir(FilePath path) throws IOException, InterruptedException {
145150
}
146151
}
147152

148-
private void appendReleaseToArguments(String release, ArgumentListBuilder args, TaskListener log) {
149-
String trimmedRelease = release.trim();
150-
String actualRelease = trimmedRelease;
153+
private MatlabRelease parseRelease(String release) throws InstallationFailedException {
154+
String name = release.trim();
155+
boolean isPrerelease = false;
151156

152-
if (trimmedRelease.equalsIgnoreCase("latest") || trimmedRelease.equalsIgnoreCase(
153-
"latest-including-prerelease")) {
154-
String releaseInfoUrl = Message.getValue("matlab.release.info.url") + trimmedRelease;
155-
String releaseVersion = null;
157+
if (name.equalsIgnoreCase("latest") || name.equalsIgnoreCase("latest-including-prerelease")) {
158+
String releaseInfoUrl = Message.getValue("matlab.release.info.url") + name;
156159
try {
157-
releaseVersion = IOUtils.toString(new URL(releaseInfoUrl),
158-
StandardCharsets.UTF_8).trim();
160+
name = IOUtils.toString(new URL(releaseInfoUrl), StandardCharsets.UTF_8).trim();
159161
} catch (IOException e) {
160-
log.getLogger().println("Failed to fetch release version: " + e.getMessage());
162+
throw new InstallationFailedException("Failed to fetch release version: " + e.getMessage());
161163
}
162164

163-
if (releaseVersion != null && releaseVersion.contains("prerelease")) {
164-
actualRelease = releaseVersion.replace("prerelease", "");
165-
args.add("--release-status=Prerelease");
166-
} else {
167-
actualRelease = releaseVersion;
165+
if (name.contains("prerelease")) {
166+
name = name.replace("prerelease", "");
167+
isPrerelease = true;
168168
}
169169
}
170-
args.add("--release=" + actualRelease);
170+
171+
return new MatlabRelease(name, isPrerelease);
171172
}
172173

173174
private FilePath fetchMpm(String platform, FilePath destination)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.mathworks.ci.tools;
2+
3+
/**
4+
* Copyright 2025, The MathWorks, Inc.
5+
*/
6+
7+
public class MatlabRelease {
8+
public String name;
9+
public boolean isPrerelease;
10+
11+
public MatlabRelease(String name, boolean isPrerelease) {
12+
this.name = name;
13+
this.isPrerelease = isPrerelease;
14+
}
15+
}

0 commit comments

Comments
 (0)