RemoteConnection (ExecutionEnvironment environment) { ParametersList programParametersList = myJavaParameters.getProgramParametersList(); boolean execGoal = ContainerUtil.exists( programParametersList.getList(), parameter -> parameter.equals("exec:exec") || EXEC_MAVEN_PLUGIN_PATTERN.matcher(parameter).matches() ); if (!execGoal) { return null; } Project project = myRunConfiguration.getProject(); MavenRunnerParameters runnerParameters = myRunConfiguration.getRunnerParameters(); JavaParameters parameters = new JavaParameters(); RemoteConnection connection; try { // there's no easy and reliable way to know the version of target JRE, but without it there won't be any debugger agent settings parameters.setJdk(JavaParametersUtil.createProjectJdk(project, null)); connection = new RemoteConnectionBuilder(false, DebuggerSettings.getInstance().getTransport(), "") .asyncAgent(true) .project(environment.getProject()) .create(parameters); } catch (ExecutionException e) { throw new RuntimeException("Cannot create debug connection", e); } String execArgsStr; String execArgsPrefix = "-Dexec.args="; int execArgsIndex = ContainerUtil.indexOf(programParametersList.getList(), s -> s.startsWith(execArgsPrefix)); if (execArgsIndex != -1) { execArgsStr = programParametersList.get(execArgsIndex).substring(execArgsPrefix.length()); } else { execArgsStr = getExecArgsFromPomXml(project, runnerParameters); } ParametersList execArgs = new ParametersList(); execArgs.addAll(MavenApplicationConfigurationExecutionEnvironmentProvider.patchVmParameters(parameters.getVMParametersList())); execArgs.addParametersString(execArgsStr); String classPath = FileUtil.toSystemDependentName(parameters.getClassPath().getPathsString()); if (StringUtil.isNotEmpty(classPath)) { appendToClassPath(execArgs, classPath); } String execArgsCommandLineArg = execArgsPrefix + execArgs.getParametersString(); if (execArgsIndex != -1) { programParametersList.set(execArgsIndex, execArgsCommandLineArg); } else { programParametersList.add(execArgsCommandLineArg); } return connection; }