2121import java .util .function .Function ;
2222import javax .annotation .Nonnull ;
2323import org .apache .commons .io .FilenameUtils ;
24+ import org .apache .commons .lang .ArrayUtils ;
2425import org .kohsuke .stapler .DataBoundConstructor ;
2526import org .kohsuke .stapler .DataBoundSetter ;
2627import 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 FilePath nodeSpecificMatlabRoot ;
5557 private String nodeSpecificfileSeparator ;
5658
5759 @ DataBoundConstructor
@@ -476,6 +478,7 @@ 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+ nodeSpecificMatlabRoot = new FilePath (launcher .getChannel (),getLocalMatlab ());
479482 nodeSpecificfileSeparator = getNodeSpecificFileSeperator (launcher );
480483
481484 // Invoke MATLAB command and transfer output to standard
@@ -493,8 +496,7 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
493496 throws IOException , InterruptedException {
494497 ProcStarter matlabLauncher ;
495498 try {
496- FilePath nodeSpecificMatlabRoot = new FilePath (launcher .getChannel (),getLocalMatlab ());
497- MatlabReleaseInfo rel = new MatlabReleaseInfo (nodeSpecificMatlabRoot );
499+ MatlabReleaseInfo rel = new MatlabReleaseInfo (this .nodeSpecificMatlabRoot );
498500 matlabLauncher = launcher .launch ().pwd (workspace ).envs (this .env );
499501 if (rel .verLessThan (MatlabBuilderConstants .BASE_MATLAB_VERSION_BATCH_SUPPORT )) {
500502 ListenerLogDecorator outStream = new ListenerLogDecorator (listener );
@@ -539,7 +541,7 @@ public List<String> constructMatlabCommandWithBatch() {
539541 return matlabDefaultArgs ;
540542 }
541543
542- public List <String > constructDefaultMatlabCommand (boolean isLinuxLauncher ) {
544+ public List <String > constructDefaultMatlabCommand (boolean isLinuxLauncher ) throws MatlabVersionNotFoundException {
543545 final List <String > matlabDefaultArgs = new ArrayList <String >();
544546 Collections .addAll (matlabDefaultArgs , getPreRunnerSwitches ());
545547 if (!isLinuxLauncher ) {
@@ -554,10 +556,14 @@ public List<String> constructDefaultMatlabCommand(boolean isLinuxLauncher) {
554556 }
555557
556558
557- private String [] getPreRunnerSwitches () {
559+ private String [] getPreRunnerSwitches () throws MatlabVersionNotFoundException {
558560 String [] preRunnerSwitches =
559561 {getLocalMatlab () + nodeSpecificfileSeparator + "bin" + nodeSpecificfileSeparator + "matlab" , "-nosplash" ,
560- "-nodesktop" , "-noAppIcon" };
562+ "-nodesktop" };
563+ MatlabReleaseInfo rel = new MatlabReleaseInfo (this .nodeSpecificMatlabRoot );
564+ if (!rel .verLessThan (MatlabBuilderConstants .BASE_MATLAB_VERSION_NO_APP_ICON_SUPPORT )) {
565+ preRunnerSwitches = (String []) ArrayUtils .add (preRunnerSwitches , "-noAppIcon" );
566+ }
561567 return preRunnerSwitches ;
562568 }
563569
0 commit comments