66 */
77
88import java .io .File ;
9- import java .io .FileInputStream ;
109import java .io .IOException ;
11- import java .io .InputStream ;
12- import java .nio .file .Files ;
1310import java .nio .file .NotDirectoryException ;
14- import java .nio .file .Paths ;
1511import java .util .HashMap ;
16- import java .util .List ;
1712import java .util .Map ;
18- import java .util .regex .Matcher ;
19- import java .util .regex .Pattern ;
20-
2113import javax .xml .parsers .DocumentBuilder ;
2214import javax .xml .parsers .DocumentBuilderFactory ;
2315import org .apache .commons .collections .MapUtils ;
3426public 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- }
0 commit comments