1
1
package com .mathworks .ci .tools ;
2
2
3
3
/**
4
- * Copyright 2024, The MathWorks, Inc.
4
+ * Copyright 2024-2025 , The MathWorks, Inc.
5
5
*/
6
6
7
7
import com .mathworks .ci .MatlabInstallation ;
@@ -49,7 +49,7 @@ public MatlabInstaller(String id) {
49
49
}
50
50
51
51
public String getRelease () {
52
- return this .release . trim () ;
52
+ return this .release ;
53
53
}
54
54
55
55
@ DataBoundSetter
@@ -75,10 +75,12 @@ public FilePath performInstallation(ToolInstallation tool, Node node, TaskListen
75
75
String extension = "" ;
76
76
String [] systemProperties = getSystemProperties (node );
77
77
FilePath matlabRoot ;
78
+ MatlabRelease release = parseRelease (this .getRelease ());
79
+
78
80
if (systemProperties [0 ].toLowerCase ().contains ("os x" )) {
79
- matlabRoot = new FilePath (toolRoot , this . getRelease () + ".app" );
81
+ matlabRoot = new FilePath (toolRoot , release . name + ".app" );
80
82
} else {
81
- matlabRoot = new FilePath (toolRoot , this . getRelease () );
83
+ matlabRoot = new FilePath (toolRoot , release . name );
82
84
}
83
85
String platform = getPlatform (systemProperties [0 ], systemProperties [1 ]);
84
86
if (platform == "win64" ) {
@@ -93,7 +95,7 @@ public FilePath performInstallation(ToolInstallation tool, Node node, TaskListen
93
95
FilePath matlabBatch = fetchMatlabBatch (platform , tempDir );
94
96
95
97
// Install with mpm
96
- mpmInstall (mpm , this . getRelease () , this .getProducts (), matlabRoot , node , log );
98
+ mpmInstall (mpm , release , this .getProducts (), matlabRoot , node , log );
97
99
98
100
// Copy downloaded matlab-batch to tool directory
99
101
FilePath matlabBin = new FilePath (matlabRoot , "bin" );
@@ -105,7 +107,7 @@ public FilePath performInstallation(ToolInstallation tool, Node node, TaskListen
105
107
return matlabRoot ;
106
108
}
107
109
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 ,
109
111
TaskListener log )
110
112
throws IOException , InterruptedException {
111
113
makeDir (destination );
@@ -115,7 +117,10 @@ private void mpmInstall(FilePath mpmPath, String release, String products, FileP
115
117
ArgumentListBuilder args = new ArgumentListBuilder ();
116
118
args .add (mpmPath .getRemote ());
117
119
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
+ }
119
124
args .add ("--destination=" + destination .getRemote ());
120
125
addMatlabProductsToArgs (args , products );
121
126
@@ -145,29 +150,25 @@ private void makeDir(FilePath path) throws IOException, InterruptedException {
145
150
}
146
151
}
147
152
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 ;
151
156
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 ;
156
159
try {
157
- releaseVersion = IOUtils .toString (new URL (releaseInfoUrl ),
158
- StandardCharsets .UTF_8 ).trim ();
160
+ name = IOUtils .toString (new URL (releaseInfoUrl ), StandardCharsets .UTF_8 ).trim ();
159
161
} 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 ());
161
163
}
162
164
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 ;
168
168
}
169
169
}
170
- args .add ("--release=" + actualRelease );
170
+
171
+ return new MatlabRelease (name , isPrerelease );
171
172
}
172
173
173
174
private FilePath fetchMpm (String platform , FilePath destination )
0 commit comments