protected void appendForkInfo(Executor executor) throws ExecutionException { final String forkMode = getForkMode(); if (Comparing.strEqual(forkMode, "none")) { if (forkPerModule()) { if (isExecutorDisabledInForkedMode()) { final String actionName = UIUtil.removeMnemonic(executor.getStartActionText()); throw new CantRunException( "'" + actionName + "' is disabled when per-module working directory is configured.<br/>" + "Please specify single working directory, or change test scope to single module."); } } else { return; } } else if (isExecutorDisabledInForkedMode()) { final String actionName = executor.getActionName(); throw new CantRunException( actionName + " is disabled in fork mode.<br/>Please change fork mode to <none> to " + actionName.toLowerCase(Locale.ENGLISH) + "."); } final JavaParameters javaParameters = getJavaParameters(); final Sdk jdk = javaParameters.getJdk(); if (jdk == null) { throw new ExecutionException( ExecutionBundle.message("run.configuration.error.no.jdk.specified")); } try { final File tempFile = FileUtil.createTempFile("command.line", "", true); final PrintWriter writer = new PrintWriter(tempFile, CharsetToolkit.UTF8); try { if (JdkUtil.useDynamicClasspath(getConfiguration().getProject())) { String classpath = PathUtil.getJarPathForClass(CommandLineWrapper.class); final String utilRtPath = PathUtil.getJarPathForClass(StringUtilRt.class); if (!classpath.equals(utilRtPath)) { classpath += File.pathSeparator + utilRtPath; } writer.println(classpath); } else { writer.println(""); } writer.println(((JavaSdkType) jdk.getSdkType()).getVMExecutablePath(jdk)); for (String vmParameter : javaParameters.getVMParametersList().getList()) { writer.println(vmParameter); } } finally { writer.close(); } passForkMode(forkMode, tempFile); } catch (Exception e) { LOG.error(e); } }
private void appendForkInfo(Executor executor) throws ExecutionException { final String forkMode = myConfiguration.getForkMode(); if (Comparing.strEqual(forkMode, "none")) { return; } if (getRunnerSettings().getData() != null) { final String actionName = executor.getActionName(); throw new CantRunException( actionName + " is disabled in fork mode.<br/>Please change fork mode to <none> to " + actionName.toLowerCase() + "."); } final JavaParameters javaParameters = getJavaParameters(); final Sdk jdk = javaParameters.getJdk(); if (jdk == null) { throw new ExecutionException( ExecutionBundle.message("run.configuration.error.no.jdk.specified")); } try { final File tempFile = FileUtil.createTempFile("command.line", "", true); final PrintWriter writer = new PrintWriter(tempFile, "UTF-8"); try { writer.println(((JavaSdkType) jdk.getSdkType()).getVMExecutablePath(jdk)); for (String vmParameter : javaParameters.getVMParametersList().getList()) { writer.println(vmParameter); } writer.println("-classpath"); writer.println(javaParameters.getClassPath().getPathsString()); } finally { writer.close(); } myJavaParameters .getProgramParametersList() .add("@@@" + forkMode + ',' + tempFile.getAbsolutePath()); } catch (Exception e) { LOG.error(e); } }