Skip to content

Commit

Permalink
resolve latest release and use that to name folder. also revert pom v…
Browse files Browse the repository at this point in the history
…ersion bump (#393)
  • Loading branch information
davidbuzinski authored Jan 8, 2025
1 parent 7eddec2 commit 7afc938
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>

<artifactId>matlab</artifactId>
<version>2.16.0-SNAPSHOT</version>
<version>2.15.1-SNAPSHOT</version>
<packaging>hpi</packaging>

<name>MATLAB Plugin</name>
Expand Down
47 changes: 24 additions & 23 deletions src/main/java/com/mathworks/ci/tools/MatlabInstaller.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mathworks.ci.tools;

/**
* Copyright 2024, The MathWorks, Inc.
* Copyright 2024-2025, The MathWorks, Inc.
*/

import com.mathworks.ci.MatlabInstallation;
Expand Down Expand Up @@ -49,7 +49,7 @@ public MatlabInstaller(String id) {
}

public String getRelease() {
return this.release.trim();
return this.release;
}

@DataBoundSetter
Expand All @@ -75,10 +75,12 @@ public FilePath performInstallation(ToolInstallation tool, Node node, TaskListen
String extension = "";
String[] systemProperties = getSystemProperties(node);
FilePath matlabRoot;
MatlabRelease release = parseRelease(this.getRelease());

if (systemProperties[0].toLowerCase().contains("os x")) {
matlabRoot = new FilePath(toolRoot, this.getRelease() + ".app");
matlabRoot = new FilePath(toolRoot, release.name + ".app");
} else {
matlabRoot = new FilePath(toolRoot, this.getRelease());
matlabRoot = new FilePath(toolRoot, release.name);
}
String platform = getPlatform(systemProperties[0], systemProperties[1]);
if (platform == "win64") {
Expand All @@ -93,7 +95,7 @@ public FilePath performInstallation(ToolInstallation tool, Node node, TaskListen
FilePath matlabBatch = fetchMatlabBatch(platform, tempDir);

// Install with mpm
mpmInstall(mpm, this.getRelease(), this.getProducts(), matlabRoot, node, log);
mpmInstall(mpm, release, this.getProducts(), matlabRoot, node, log);

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

private void mpmInstall(FilePath mpmPath, String release, String products, FilePath destination, Node node,
private void mpmInstall(FilePath mpmPath, MatlabRelease release, String products, FilePath destination, Node node,
TaskListener log)
throws IOException, InterruptedException {
makeDir(destination);
Expand All @@ -115,7 +117,10 @@ private void mpmInstall(FilePath mpmPath, String release, String products, FileP
ArgumentListBuilder args = new ArgumentListBuilder();
args.add(mpmPath.getRemote());
args.add("install");
appendReleaseToArguments(release, args, log);
args.add("--release=" + release.name);
if (release.isPrerelease) {
args.add("--release-status=Prerelease");
}
args.add("--destination=" + destination.getRemote());
addMatlabProductsToArgs(args, products);

Expand Down Expand Up @@ -145,29 +150,25 @@ private void makeDir(FilePath path) throws IOException, InterruptedException {
}
}

private void appendReleaseToArguments(String release, ArgumentListBuilder args, TaskListener log) {
String trimmedRelease = release.trim();
String actualRelease = trimmedRelease;
private MatlabRelease parseRelease(String release) throws InstallationFailedException {
String name = release.trim();
boolean isPrerelease = false;

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

if (releaseVersion != null && releaseVersion.contains("prerelease")) {
actualRelease = releaseVersion.replace("prerelease", "");
args.add("--release-status=Prerelease");
} else {
actualRelease = releaseVersion;
if (name.contains("prerelease")) {
name = name.replace("prerelease", "");
isPrerelease = true;
}
}
args.add("--release=" + actualRelease);

return new MatlabRelease(name, isPrerelease);
}

private FilePath fetchMpm(String platform, FilePath destination)
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/mathworks/ci/tools/MatlabRelease.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.mathworks.ci.tools;

/**
* Copyright 2025, The MathWorks, Inc.
*/

public class MatlabRelease {
public String name;
public boolean isPrerelease;

public MatlabRelease(String name, boolean isPrerelease) {
this.name = name;
this.isPrerelease = isPrerelease;
}
}

0 comments on commit 7afc938

Please sign in to comment.