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

Commit 5c9f61a

Browse files
authored
Merge pull request #62 from mathworks/Git-issue-41_noappicon_support
Version check for noAppIcon startup option.
2 parents c88eb0d + a820a54 commit 5c9f61a

File tree

5 files changed

+257
-6
lines changed

5 files changed

+257
-6
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.function.Function;
2222
import javax.annotation.Nonnull;
2323
import org.apache.commons.io.FilenameUtils;
24+
import org.apache.commons.lang.ArrayUtils;
2425
import org.kohsuke.stapler.DataBoundConstructor;
2526
import org.kohsuke.stapler.DataBoundSetter;
2627
import org.kohsuke.stapler.QueryParameter;
@@ -52,6 +53,7 @@ public class MatlabBuilder extends Builder implements SimpleBuildStep {
5253
private TestRunTypeList testRunTypeList;
5354
private String matlabRoot;
5455
private EnvVars env;
56+
private MatlabReleaseInfo matlabRel;
5557
private String nodeSpecificfileSeparator;
5658

5759
@DataBoundConstructor
@@ -476,6 +478,9 @@ public void perform(@Nonnull Run<?, ?> build, @Nonnull FilePath workspace,
476478
throws InterruptedException, IOException {
477479
//Set the environment variable specific to the this build
478480
setEnv(build.getEnvironment(listener));
481+
//Get node specific matlabroot to get matlab version information
482+
FilePath nodeSpecificMatlabRoot = new FilePath(launcher.getChannel(),getLocalMatlab());
483+
matlabRel = new MatlabReleaseInfo(nodeSpecificMatlabRoot);
479484
nodeSpecificfileSeparator = getNodeSpecificFileSeperator(launcher);
480485

481486
// Invoke MATLAB command and transfer output to standard
@@ -493,10 +498,8 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
493498
throws IOException, InterruptedException {
494499
ProcStarter matlabLauncher;
495500
try {
496-
FilePath nodeSpecificMatlabRoot = new FilePath(launcher.getChannel(),getLocalMatlab());
497-
MatlabReleaseInfo rel = new MatlabReleaseInfo(nodeSpecificMatlabRoot);
498501
matlabLauncher = launcher.launch().pwd(workspace).envs(this.env);
499-
if (rel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_BATCH_SUPPORT)) {
502+
if (matlabRel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_BATCH_SUPPORT)) {
500503
ListenerLogDecorator outStream = new ListenerLogDecorator(listener);
501504
matlabLauncher = matlabLauncher.cmds(constructDefaultMatlabCommand(launcher.isUnix())).stderr(outStream);
502505
} else {
@@ -539,7 +542,7 @@ public List<String> constructMatlabCommandWithBatch() {
539542
return matlabDefaultArgs;
540543
}
541544

542-
public List<String> constructDefaultMatlabCommand(boolean isLinuxLauncher) {
545+
public List<String> constructDefaultMatlabCommand(boolean isLinuxLauncher) throws MatlabVersionNotFoundException {
543546
final List<String> matlabDefaultArgs = new ArrayList<String>();
544547
Collections.addAll(matlabDefaultArgs, getPreRunnerSwitches());
545548
if (!isLinuxLauncher) {
@@ -554,10 +557,13 @@ public List<String> constructDefaultMatlabCommand(boolean isLinuxLauncher) {
554557
}
555558

556559

557-
private String[] getPreRunnerSwitches() {
560+
private String[] getPreRunnerSwitches() throws MatlabVersionNotFoundException {
558561
String[] preRunnerSwitches =
559562
{getLocalMatlab() + nodeSpecificfileSeparator + "bin" + nodeSpecificfileSeparator + "matlab", "-nosplash",
560-
"-nodesktop", "-noAppIcon"};
563+
"-nodesktop"};
564+
if(!matlabRel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_NO_APP_ICON_SUPPORT)) {
565+
preRunnerSwitches = (String[]) ArrayUtils.add(preRunnerSwitches, "-noAppIcon");
566+
}
561567
return preRunnerSwitches;
562568
}
563569

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
public class MatlabBuilderConstants {
77
static final double BASE_MATLAB_VERSION_RUNTESTS_SUPPORT = 8.1;
8+
static final double BASE_MATLAB_VERSION_NO_APP_ICON_SUPPORT = 8.6;
89
static final double BASE_MATLAB_VERSION_BATCH_SUPPORT = 9.5;
910
static final double BASE_MATLAB_VERSION_COBERTURA_SUPPORT = 9.3;
1011
static final double BASE_MATLAB_VERSION_MODELCOVERAGE_SUPPORT = 9.5;

src/test/java/com/mathworks/ci/MatlabBuilderTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,30 @@ public void verifyEnvVarSupportForCustomCommandField() throws Exception {
537537

538538
}
539539

540+
/*
541+
* Test to verify -noAppIcon is not displayed for MATLAB version R2015a
542+
*/
543+
544+
@Test
545+
public void verifyNoAppIconForR2015a() throws Exception {
546+
this.matlabBuilder.setMatlabRoot(getMatlabroot("R2015a"));
547+
FreeStyleBuild build = getBuildforRunTestAutomatically();
548+
jenkins.assertLogContains("-r", build);
549+
jenkins.assertLogNotContains("-noAppIcon", build);
550+
}
551+
552+
/*
553+
* Test to verify -noAppIcon is displayed for MATLAB version R2015b
554+
*/
555+
556+
@Test
557+
public void verifyNoAppIconForR2015b() throws Exception {
558+
this.matlabBuilder.setMatlabRoot(getMatlabroot("R2015b"));
559+
FreeStyleBuild build = getBuildforRunTestAutomatically();
560+
jenkins.assertLogContains("-r", build);
561+
jenkins.assertLogContains("-noAppIcon", build);
562+
}
563+
540564
/*
541565
* Private helper methods for tests
542566
*/
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
% General purpose commands.
2+
% MATLAB Version 8.5 (R2015a) 19-Feb-2015
3+
%
4+
% General information.
5+
% syntax - Help on MATLAB command syntax.
6+
% demo - Run demonstrations.
7+
% ver - MATLAB, Simulink and toolbox version information.
8+
% version - MATLAB version information.
9+
% verLessThan - Compare version of toolbox to specified version string.
10+
% logo - Plot the L-shaped membrane logo with MATLAB lighting.
11+
% membrane - Generates the MATLAB logo.
12+
% bench - MATLAB Benchmark.
13+
%
14+
% Managing the workspace.
15+
% who - List current variables.
16+
% whos - List current variables, long form.
17+
% clear - Clear variables and functions from memory.
18+
% onCleanup - Specify cleanup work to be done on function completion.
19+
% pack - Consolidate workspace memory.
20+
% load - Load workspace variables from disk.
21+
% save - Save workspace variables to disk.
22+
% saveas - Save Figure or model to desired output format.
23+
% memory - Help for memory limitations.
24+
% recycle - Set option to move deleted files to recycle folder.
25+
% quit - Quit MATLAB session.
26+
% exit - Exit from MATLAB.
27+
%
28+
% Managing commands and functions.
29+
% what - List MATLAB-specific files in directory.
30+
% type - Display MATLAB program file.
31+
% open - Open files by extension.
32+
% which - Locate functions and files.
33+
% pcode - Create pre-parsed pseudo-code file (P-file).
34+
% mex - Compile MEX-function.
35+
% inmem - List functions in memory.
36+
% namelengthmax - Maximum length of MATLAB function or variable name.
37+
%
38+
% Managing the search path.
39+
% path - Get/set search path.
40+
% addpath - Add directory to search path.
41+
% rmpath - Remove directory from search path.
42+
% rehash - Refresh function and file system caches.
43+
% import - Import packages into the current scope.
44+
% finfo - Identify file type against standard file handlers on path.
45+
% genpath - Generate recursive toolbox path.
46+
% savepath - Save the current MATLAB path in the pathdef.m file.
47+
%
48+
% Managing the java search path.
49+
% javaaddpath - Add directories to the dynamic java path.
50+
% javaclasspath - Get and set java path.
51+
% javarmpath - Remove directory from dynamic java path.
52+
%
53+
% Controlling the command window.
54+
% echo - Display statements during function execution.
55+
% more - Control paged output in command window.
56+
% diary - Save text of MATLAB session.
57+
% format - Set output format.
58+
% beep - Produce beep sound.
59+
% desktop - Start and query the MATLAB Desktop.
60+
% preferences - Bring up MATLAB user settable preferences dialog.
61+
%
62+
% Operating system commands.
63+
% cd - Change current working directory.
64+
% copyfile - Copy file or directory.
65+
% movefile - Move file or directory.
66+
% delete - Delete file or graphics object.
67+
% pwd - Show (print) current working directory.
68+
% dir - List directory.
69+
% ls - List directory.
70+
% fileattrib - Set or get attributes of files and directories.
71+
% isdir - True if argument is a directory.
72+
% mkdir - Make new directory.
73+
% rmdir - Remove directory.
74+
% getenv - Get environment variable.
75+
% ! - Execute operating system command (see PUNCT).
76+
% dos - Execute DOS command and return result.
77+
% unix - Execute UNIX command and return result.
78+
% system - Execute system command and return result.
79+
% perl - Execute Perl command and return the result.
80+
% computer - Computer type.
81+
% isunix - True for the UNIX version of MATLAB.
82+
% ispc - True for the PC (Windows) version of MATLAB.
83+
%
84+
% Debugging.
85+
% debug - List debugging commands.
86+
%
87+
% Tools to locate dependent functions of a program file.
88+
% depfun - Locate dependent functions of program file.
89+
% depdir - Locate dependent directories of program file.
90+
%
91+
% Loading and calling shared libraries.
92+
% calllib - Call a function in an external library.
93+
% libpointer - Creates a pointer object for use with external libraries.
94+
% libstruct - Creates a structure pointer for use with external libraries.
95+
% libisloaded - True if the specified shared library is loaded.
96+
% loadlibrary - Load a shared library into MATLAB.
97+
% libfunctions - Return information on functions in an external library.
98+
% libfunctionsview - View the functions in an external library.
99+
% unloadlibrary - Unload a shared library loaded with LOADLIBRARY.
100+
% java - Using Java from within MATLAB.
101+
% usejava - True if the specified Java feature is supported in MATLAB.
102+
%
103+
% See also LANG, DATATYPES, IOFUN, GRAPHICS, OPS, STRFUN, TIMEFUN,
104+
% MATFUN, DEMOS, GRAPHICS, DATAFUN, UITOOLS, DOC, PUNCT, ARITH.
105+
106+
% Controlling multithreading setting.
107+
% maxNumCompThreads - Controls the maximum number of computational threads.
108+
109+
% Copyright 1984-2015 The MathWorks, Inc.
110+
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
% General purpose commands.
2+
% MATLAB Version 8.6 (R2015b) 13-Aug-2015
3+
%
4+
% General information.
5+
% syntax - Help on MATLAB command syntax.
6+
% demo - Run demonstrations.
7+
% ver - MATLAB, Simulink and toolbox version information.
8+
% version - MATLAB version information.
9+
% verLessThan - Compare version of toolbox to specified version string.
10+
% logo - Plot the L-shaped membrane logo with MATLAB lighting.
11+
% membrane - Generates the MATLAB logo.
12+
% bench - MATLAB Benchmark.
13+
%
14+
% Managing the workspace.
15+
% who - List current variables.
16+
% whos - List current variables, long form.
17+
% clear - Clear variables and functions from memory.
18+
% onCleanup - Specify cleanup work to be done on function completion.
19+
% pack - Consolidate workspace memory.
20+
% load - Load workspace variables from disk.
21+
% save - Save workspace variables to disk.
22+
% saveas - Save Figure or model to desired output format.
23+
% memory - Help for memory limitations.
24+
% recycle - Set option to move deleted files to recycle folder.
25+
% quit - Quit MATLAB session.
26+
% exit - Exit from MATLAB.
27+
%
28+
% Managing commands and functions.
29+
% what - List MATLAB-specific files in directory.
30+
% type - Display MATLAB program file.
31+
% open - Open files by extension.
32+
% which - Locate functions and files.
33+
% pcode - Create pre-parsed pseudo-code file (P-file).
34+
% mex - Compile MEX-function.
35+
% inmem - List functions in memory.
36+
% namelengthmax - Maximum length of MATLAB function or variable name.
37+
%
38+
% Managing the search path.
39+
% path - Get/set search path.
40+
% addpath - Add directory to search path.
41+
% rmpath - Remove directory from search path.
42+
% rehash - Refresh function and file system caches.
43+
% import - Import packages into the current scope.
44+
% finfo - Identify file type against standard file handlers on path.
45+
% genpath - Generate recursive toolbox path.
46+
% savepath - Save the current MATLAB path in the pathdef.m file.
47+
%
48+
% Managing the java search path.
49+
% javaaddpath - Add directories to the dynamic java path.
50+
% javaclasspath - Get and set java path.
51+
% javarmpath - Remove directory from dynamic java path.
52+
%
53+
% Controlling the command window.
54+
% echo - Display statements during function execution.
55+
% more - Control paged output in command window.
56+
% diary - Save text of MATLAB session.
57+
% format - Set output format.
58+
% beep - Produce beep sound.
59+
% desktop - Start and query the MATLAB Desktop.
60+
% preferences - Bring up MATLAB user settable preferences dialog.
61+
%
62+
% Operating system commands.
63+
% cd - Change current working directory.
64+
% copyfile - Copy file or directory.
65+
% movefile - Move file or directory.
66+
% delete - Delete file or graphics object.
67+
% pwd - Show (print) current working directory.
68+
% dir - List directory.
69+
% ls - List directory.
70+
% fileattrib - Set or get attributes of files and directories.
71+
% isdir - True if argument is a directory.
72+
% mkdir - Make new directory.
73+
% rmdir - Remove directory.
74+
% getenv - Get environment variable.
75+
% ! - Execute operating system command (see PUNCT).
76+
% dos - Execute DOS command and return result.
77+
% unix - Execute UNIX command and return result.
78+
% system - Execute system command and return result.
79+
% perl - Execute Perl command and return the result.
80+
% computer - Computer type.
81+
% isunix - True for the UNIX version of MATLAB.
82+
% ispc - True for the PC (Windows) version of MATLAB.
83+
%
84+
% Debugging.
85+
% debug - List debugging commands.
86+
%
87+
% Tools to locate dependent functions of a program file.
88+
% depfun - Locate dependent functions of program file.
89+
% depdir - Locate dependent directories of program file.
90+
%
91+
% Loading and calling shared libraries.
92+
% calllib - Call a function in an external library.
93+
% libpointer - Creates a pointer object for use with external libraries.
94+
% libstruct - Creates a structure pointer for use with external libraries.
95+
% libisloaded - True if the specified shared library is loaded.
96+
% loadlibrary - Load a shared library into MATLAB.
97+
% libfunctions - Return information on functions in an external library.
98+
% libfunctionsview - View the functions in an external library.
99+
% unloadlibrary - Unload a shared library loaded with LOADLIBRARY.
100+
% java - Using Java from within MATLAB.
101+
% usejava - True if the specified Java feature is supported in MATLAB.
102+
%
103+
% See also LANG, DATATYPES, IOFUN, GRAPHICS, OPS, STRFUN, TIMEFUN,
104+
% MATFUN, DEMOS, GRAPHICS, DATAFUN, UITOOLS, DOC, PUNCT, ARITH.
105+
106+
% Controlling multithreading setting.
107+
% maxNumCompThreads - Controls the maximum number of computational threads.
108+
109+
% Copyright 1984-2015 The MathWorks, Inc.
110+

0 commit comments

Comments
 (0)