11package com .mathworks .ci .tools ;
22
33/**
4- * Copyright 2024, The MathWorks, Inc.
4+ * Copyright 2024-2025 , The MathWorks, Inc.
55 */
66
77import 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 )
0 commit comments