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

Commit 44e6825

Browse files
committed
Revert "Added version finding capability with Contents file."
This reverts commit 80cb0cd.
1 parent 80cb0cd commit 44e6825

File tree

3 files changed

+7
-157
lines changed

3 files changed

+7
-157
lines changed

src/main/java/com/mathworks/ci/MatlabBuilder.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class MatlabBuilder extends Builder implements SimpleBuildStep {
5353
private TestRunTypeList testRunTypeList;
5454
private String matlabRoot;
5555
private EnvVars env;
56-
private MatlabReleaseInfo matlabRel;
56+
private FilePath nodeSpecificMatlabRoot;
5757
private String nodeSpecificfileSeparator;
5858

5959
@DataBoundConstructor
@@ -478,10 +478,7 @@ public void perform(@Nonnull Run<?, ?> build, @Nonnull FilePath workspace,
478478
throws InterruptedException, IOException {
479479
//Set the environment variable specific to the this build
480480
setEnv(build.getEnvironment(listener));
481-
482-
// Get node specific matlabroot to get MATLAB version information
483-
FilePath nodeSpecificMatlabRoot = new FilePath(launcher.getChannel(),getLocalMatlab());
484-
matlabRel = new MatlabReleaseInfo(nodeSpecificMatlabRoot);
481+
nodeSpecificMatlabRoot = new FilePath(launcher.getChannel(),getLocalMatlab());
485482
nodeSpecificfileSeparator = getNodeSpecificFileSeperator(launcher);
486483

487484
// Invoke MATLAB command and transfer output to standard
@@ -499,8 +496,9 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
499496
throws IOException, InterruptedException {
500497
ProcStarter matlabLauncher;
501498
try {
499+
MatlabReleaseInfo rel = new MatlabReleaseInfo(this.nodeSpecificMatlabRoot);
502500
matlabLauncher = launcher.launch().pwd(workspace).envs(this.env);
503-
if (matlabRel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_BATCH_SUPPORT)) {
501+
if (rel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_BATCH_SUPPORT)) {
504502
ListenerLogDecorator outStream = new ListenerLogDecorator(listener);
505503
matlabLauncher = matlabLauncher.cmds(constructDefaultMatlabCommand(launcher.isUnix())).stderr(outStream);
506504
} else {
@@ -562,7 +560,8 @@ private String[] getPreRunnerSwitches() throws MatlabVersionNotFoundException {
562560
String[] preRunnerSwitches =
563561
{getLocalMatlab() + nodeSpecificfileSeparator + "bin" + nodeSpecificfileSeparator + "matlab", "-nosplash",
564562
"-nodesktop"};
565-
if(!matlabRel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_NO_APP_ICON_SUPPORT)) {
563+
MatlabReleaseInfo rel = new MatlabReleaseInfo(this.nodeSpecificMatlabRoot);
564+
if(!rel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_NO_APP_ICON_SUPPORT)) {
566565
preRunnerSwitches = (String[]) ArrayUtils.add(preRunnerSwitches, "-noAppIcon");
567566
}
568567
return preRunnerSwitches;

src/main/java/com/mathworks/ci/MatlabReleaseInfo.java

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,10 @@
66
*/
77

88
import java.io.File;
9-
import java.io.FileInputStream;
109
import java.io.IOException;
11-
import java.io.InputStream;
12-
import java.nio.file.Files;
1310
import java.nio.file.NotDirectoryException;
14-
import java.nio.file.Paths;
1511
import java.util.HashMap;
16-
import java.util.List;
1712
import java.util.Map;
18-
import java.util.regex.Matcher;
19-
import java.util.regex.Pattern;
20-
2113
import javax.xml.parsers.DocumentBuilder;
2214
import javax.xml.parsers.DocumentBuilderFactory;
2315
import org.apache.commons.collections.MapUtils;
@@ -34,8 +26,6 @@
3426
public class MatlabReleaseInfo {
3527
private FilePath matlabRoot;
3628
private static final String VERSION_INFO_FILE = "VersionInfo.xml";
37-
private static final String CONTENTS_FILE = "Contents.m";
38-
private static final String VERSION_PATTERN = "(\\d+)\\.(\\d+)";
3929
private static final String VERSION_INFO_ROOT_TAG = "MathWorks_version_info";
4030
private static final String RELEASE_TAG = "release";
4131
private static final String VERSION_TAG = "version";
@@ -117,18 +107,7 @@ private Map<String, String> getVersionInfoFromFile() throws MatlabVersionNotFoun
117107
else if(!this.matlabRoot.exists()){
118108
throw new NotDirectoryException("Invalid matlabroot path");
119109
}else {
120-
// Get the version information from Contents.m file
121-
String versionLine = this.matlabRoot.act(new ContentsVersion());
122-
123-
// Setting actual version to default R2016b
124-
String actualVersion = VERSION_16B;
125-
Pattern p = Pattern.compile(VERSION_PATTERN);
126-
Matcher m = p.matcher(versionLine);
127-
if(m.find()) {
128-
actualVersion = m.group();
129-
}
130-
// Update the versionInfoCache with actual version extracted from Contents.m file
131-
versionInfoCache.put(VERSION_TAG, actualVersion);
110+
versionInfoCache.putAll(VERSION_OLDER_THAN_17A);
132111
}
133112

134113
} catch (Exception e) {
@@ -139,22 +118,3 @@ else if(!this.matlabRoot.exists()){
139118
return versionInfoCache;
140119
}
141120
}
142-
143-
//Below piece of code will be executed on the specific node in case of job is running on remote agent.
144-
final class ContentsVersion implements FileCallable<String> {
145-
private static final long serialVersionUID = 1;
146-
147-
// File path of Contents.m on specific node
148-
private static String CONTENTS_FILE = "toolbox" + File.separator + "matlab" + File.separator + "general" + File.separator + "Contents.m";
149-
@Override
150-
public String invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
151-
List<String> line = Files.readAllLines(Paths.get(f.getPath() + File.separator + CONTENTS_FILE));
152-
// Get second line from Contents.m file
153-
return line.get(1);
154-
}
155-
@Override
156-
public void checkRoles(RoleChecker checker) throws SecurityException {
157-
// No Roles to check
158-
159-
}
160-
}

src/test/resources/versioninfo/R2016b/toolbox/matlab/general/Contents.m

Lines changed: 0 additions & 109 deletions
This file was deleted.

0 commit comments

Comments
 (0)