diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/core/ant/CliScriptGenerator.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/core/ant/CliScriptGenerator.java index c7c6a56bee03a9c33a2599fbe254697a7345a500..1e0ea575c1df100dc5c494d203ca842702a56e48 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/core/ant/CliScriptGenerator.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/core/ant/CliScriptGenerator.java @@ -34,7 +34,8 @@ public final class CliScriptGenerator { private static final String SHELL_SCRIPT_HEADER = "#!/usr/bin/env sh\n"; private static final String SHELL_SCRIPT_TEXT = "function help() {\n" - + "\techo \"usage: " + SHELL_SCRIPT_NAME + " executable.jar config.cfg [-m|--mode execution_mode] [-p|--project project_name]\"\n" + + "\techo \"usage: " + SHELL_SCRIPT_NAME + " executable.jar config.cfg [-m|--mode execution_mode] " + + "[-p|--project project_name] [-vmargs \"arguments_for_jvm\"]\"\n" + "\techo \" -m|--mode [hc|host_controller|mc|main_controller|p|parallel|s|single]\"\n" + "}\n\n" + "function proc_mode() {\n" @@ -64,11 +65,11 @@ public final class CliScriptGenerator { + "\tfi\n" + "\techo \"Starting the Host Controller...\"\n" + "\techo \"Connecting to ${localaddress}:${tcpport}...\"\n" - + "\tjava -Dfile.encoding=UTF-8 -cp ${exe_file} org.eclipse.titan.${project}.generated.Parallel_main ${localaddress} ${tcpport}\n" + + "\tjava ${vmargs} -cp ${exe_file} org.eclipse.titan.${project}.generated.Parallel_main ${localaddress} ${tcpport}\n" + "}\n\n" + "function start_mc() {\n" + "\techo \"Starting the Main Controller...\"\n" - + "\tjava -Dfile.encoding=UTF-8 -cp ${exe_file} org.eclipse.titan.runtime.core.mctr.CliMain ${cfg_file}\n" + + "\tjava ${vmargs} -cp ${exe_file} org.eclipse.titan.runtime.core.mctr.CliMain ${cfg_file}\n" + "}\n\n" + "function start_parallel() {\n" + "\techo \"Starting automatic execution in Parallel mode...\"\n" @@ -80,7 +81,7 @@ public final class CliScriptGenerator { + "}\n\n" + "function start_single() {\n" + "\techo \"Starting execution in Single mode...\"\n" - + "\tjava -Dfile.encoding=UTF-8 -cp ${exe_file} org.eclipse.titan.${project}.generated.Single_main ${cfg_file}\n" + + "\tjava ${vmargs} -cp ${exe_file} org.eclipse.titan.${project}.generated.Single_main ${cfg_file}\n" + "}\n\n" + "if [ ! -e \"$(which java)\" ]; then\n" + "\techo \"java is not found.\"\n" @@ -89,10 +90,11 @@ public final class CliScriptGenerator { + "exe_file=\"\"\n" + "project=\"\"\n" + "mode=\"parallel\"\n" + + "vmargs=\"-Dfile.encoding=UTF-8\"\n" + "while [ -n \"$1\" ]; do\n" + "\tcase \"$1\" in\n" - + "\t\t-h) help; exit 1;;\n" - + "\t\t--help) help; exit 1;;\n" + + "\t\t-h) help; exit 0;;\n" + + "\t\t--help) help; exit 0;;\n" + "\t\t-m) \n" + "\t\t\tif [ -n \"$2\" ]; then\n" + "\t\t\t\tmode=$2; shift\n" @@ -117,6 +119,12 @@ public final class CliScriptGenerator { + "\t\t\telse\n" + "\t\t\t\techo \"Project name option is empty. Using default: ${project}\"\n" + "\t\t\tfi;;\n" + + "\t\t-vmargs)\n" + + "\t\t\tif [ -n \"$2\" ]; then\n" + + "\t\t\t\tvmargs=$2; shift\n" + + "\t\t\telse\n" + + "\t\t\t\techo \"VM arguments option is empty. Using default: \\\"${vmargs}\\\"\"\n" + + "\t\t\tfi;;\n" + "\t\t*) \n" + "\t\t\tif [[ $1 =~ .*.(jar|zip) ]]; then\n" + "\t\t\t\texe_file=$1 \n" @@ -306,6 +314,13 @@ public final class CliScriptGenerator { if (shellScriptContent != null) { File shellScriptFile = new File(jarFolderString + File.separator + SHELL_SCRIPT_NAME); IOUtils.writeStringToFile(shellScriptFile, shellScriptContent); + try { + if (!shellScriptFile.setExecutable(true, false)) + if (!shellScriptFile.setExecutable(true, true)) + throw new SecurityException(); + } catch (SecurityException e) { + ErrorReporter.logWarning("Setting execution permission for '" + SHELL_SCRIPT_NAME + "' failed."); + } project.refreshLocal(IResource.DEPTH_INFINITE, null); } if (cmdScriptContent != null) {