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

Commit 328d9eb

Browse files
committed
Updated product list logic
1 parent 028510f commit 328d9eb

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public FilePath performInstallation (ToolInstallation tool, Node node, TaskListe
9191
if (versionInfo.exists () && isSameProduct(installedProducts)) {
9292
return expectedPath;
9393
} else {
94-
int result = installUsingMpm (node, expectedPath, log);
94+
int result = installUsingMpm (node, expectedPath, log, installedProducts);
9595
if (result == 0) {
9696
log.getLogger ().println (
9797
"MATLAB installation for version " + this.getVersion ()
@@ -102,8 +102,8 @@ public FilePath performInstallation (ToolInstallation tool, Node node, TaskListe
102102
return expectedPath;
103103
}
104104

105-
private int installUsingMpm (Node node, FilePath expectedPath, TaskListener log)
106-
throws IOException {
105+
private int installUsingMpm (Node node, FilePath expectedPath, TaskListener log, FilePath installedProducts)
106+
throws IOException, InterruptedException {
107107

108108
Launcher matlabInstaller = node.createLauncher (log);
109109
ProcStarter installerProc = matlabInstaller.launch ();
@@ -113,7 +113,7 @@ private int installUsingMpm (Node node, FilePath expectedPath, TaskListener log)
113113
args.add ("install");
114114
appendReleaseToArguments (args, log);
115115
args.add ("--destination=" + expectedPath.getRemote ());
116-
addMatlabProductsToArgs (args);
116+
addMatlabProductsToArgs (args, installedProducts);
117117
installerProc.pwd (expectedPath).cmds (args).stdout (log);
118118
int result;
119119
try {
@@ -163,7 +163,7 @@ private void updateProductList (FilePath installedProducts)
163163
Set<String> productSet;
164164
while ((line = reader.readLine ()) != null) {
165165
productSet = new HashSet<> (
166-
Arrays.asList (line.trim () + " " + this.getProducts ().trim ()));
166+
Arrays.asList ((line.trim () + " " + this.getProducts ().trim()).split (" ")));
167167
installedProducts.write (String.join (" ", productSet),
168168
StandardCharsets.UTF_8.name ());
169169
}
@@ -224,16 +224,21 @@ private String getNodeSpecificMPMExecutor (Node node) {
224224
return "/mpm";
225225
}
226226

227-
private void addMatlabProductsToArgs (ArgumentListBuilder args) {
227+
private void addMatlabProductsToArgs (ArgumentListBuilder args, FilePath installedProducts)
228+
throws IOException, InterruptedException {
228229
args.add ("--products");
229230
if (!this.getProducts ().isEmpty ()) {
230-
args.add ("MATLAB");
231+
if(!installedProducts.exists ()){
232+
args.add ("MATLAB");
233+
}
231234
String[] productList = this.getProducts ().split (" ");
232235
for (String prod : productList) {
233236
args.add (prod);
234237
}
235238
} else {
236-
args.add ("MATLAB");
239+
if(!installedProducts.exists ()){
240+
args.add ("MATLAB");
241+
}
237242
}
238243
}
239244

0 commit comments

Comments
 (0)