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

Commit 22b2351

Browse files
committed
Removed product hash
1 parent c822a0f commit 22b2351

File tree

1 file changed

+11
-71
lines changed

1 file changed

+11
-71
lines changed

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

Lines changed: 11 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public class MatlabInstaller extends DownloadFromUrlInstaller {
4949

5050
private String version;
5151
private String products;
52+
private static String DEFAULT_PRODUCT = "MATLAB";
5253

5354
@DataBoundConstructor
5455
public MatlabInstaller (String id) {
@@ -88,23 +89,16 @@ public FilePath performInstallation (ToolInstallation tool, Node node, TaskListe
8889
getFreshCopyOfExecutables (installable, supportingExecutable);
8990
makeDir (expectedPath);
9091

91-
FilePath versionInfo = new FilePath (expectedPath,"VersionInfo.xml");
92-
FilePath installedProducts = new FilePath (expectedPath,"installed_matlab_product_list.txt");
93-
if (versionInfo.exists () && isSameProduct(installedProducts)) {
94-
return expectedPath;
95-
} else {
96-
int result = installUsingMpm (node, expectedPath, log, installedProducts);
92+
int result = installUsingMpm (node, expectedPath, log);
9793
if (result == 0) {
9894
log.getLogger ().println (
9995
"MATLAB installation of version " + this.getVersion ()
10096
+ " using mpm completed successfully!");
101-
updateProductList (installedProducts);
10297
}
103-
}
10498
return expectedPath;
10599
}
106100

107-
private int installUsingMpm (Node node, FilePath destination, TaskListener log, FilePath installedProducts)
101+
private int installUsingMpm (Node node, FilePath destination, TaskListener log)
108102
throws IOException, InterruptedException {
109103

110104
Launcher matlabInstaller = node.createLauncher (log);
@@ -115,7 +109,7 @@ private int installUsingMpm (Node node, FilePath destination, TaskListener log,
115109
args.add ("install");
116110
appendReleaseToArguments (args, log);
117111
args.add ("--destination=" + destination.getRemote ());
118-
addMatlabProductsToArgs (args, installedProducts);
112+
addMatlabProductsToArgs (args);
119113
installerProc.pwd (destination).cmds (args).stdout (log);
120114
int result;
121115
try {
@@ -134,59 +128,6 @@ private void makeDir(FilePath path) throws IOException, InterruptedException {
134128
}
135129
}
136130

137-
private boolean isSameProduct (FilePath installedProducts)
138-
throws IOException, InterruptedException {
139-
if (installedProducts.exists ()) {
140-
Set<String> productSet;
141-
if (this.getProducts().isEmpty ()) {
142-
// Add default product if no products are provided
143-
productSet = new HashSet<>(Arrays.asList("MATLAB"));
144-
} else {
145-
productSet = new HashSet<>(Arrays.asList(this.getProducts().trim().split(" ")));
146-
}
147-
148-
try (BufferedReader reader = new BufferedReader (
149-
new InputStreamReader (installedProducts.read (), StandardCharsets.UTF_8.name ()))) {
150-
String line;
151-
Set<String> foundProducts = new HashSet<> ();
152-
while ((line = reader.readLine()) != null) {
153-
for (String product : productSet) {
154-
if (line.trim().contains (product)) {
155-
foundProducts.add (product);
156-
}
157-
}
158-
}
159-
return foundProducts.containsAll(productSet);
160-
}
161-
}
162-
return false;
163-
}
164-
165-
private void updateProductList (FilePath installedProducts)
166-
throws IOException, InterruptedException {
167-
String productList = this.getProducts ();
168-
if (installedProducts.exists ()) {
169-
try (BufferedReader reader = new BufferedReader (
170-
new InputStreamReader (installedProducts.read (), StandardCharsets.UTF_8.name ()))) {
171-
String line;
172-
Set<String> productSet;
173-
while ((line = reader.readLine ()) != null) {
174-
productSet = new HashSet<> (
175-
Arrays.asList ((line.trim () + " " + this.getProducts ().trim()).split (" ")));
176-
installedProducts.write (String.join (" ", productSet),
177-
StandardCharsets.UTF_8.name ());
178-
}
179-
}
180-
} else {
181-
if (productList.isEmpty ()) {
182-
installedProducts.write ("MATLAB", StandardCharsets.UTF_8.name ());
183-
} else {
184-
installedProducts.write ("MATLAB " + this.getProducts (),
185-
StandardCharsets.UTF_8.name ());
186-
}
187-
}
188-
}
189-
190131
private void appendReleaseToArguments (ArgumentListBuilder args, TaskListener log) {
191132
String trimmedRelease = this.getVersion ().trim ();
192133
String actualRelease = trimmedRelease;
@@ -233,21 +174,20 @@ private String getNodeSpecificMPMExecutor (Node node) {
233174
return "/mpm";
234175
}
235176

236-
private void addMatlabProductsToArgs (ArgumentListBuilder args, FilePath installedProducts)
177+
private void addMatlabProductsToArgs (ArgumentListBuilder args)
237178
throws IOException, InterruptedException {
238179
args.add ("--products");
239-
if (!this.getProducts ().isEmpty ()) {
240-
if(!installedProducts.exists ()){
241-
args.add ("MATLAB");
180+
if (this.getProducts ().isEmpty ()) {
181+
args.add (DEFAULT_PRODUCT);
182+
183+
} else {
184+
if (!this.getProducts ().contains (DEFAULT_PRODUCT)) {
185+
args.add (DEFAULT_PRODUCT);
242186
}
243187
String[] productList = this.getProducts ().split (" ");
244188
for (String prod : productList) {
245189
args.add (prod);
246190
}
247-
} else {
248-
if(!installedProducts.exists ()){
249-
args.add ("MATLAB");
250-
}
251191
}
252192
}
253193

0 commit comments

Comments
 (0)