void (@NotNull List<String> taskNames, @Nullable String jvmParametersSetup, @NotNull Consumer<String> initScriptConsumer) { if (!StringUtil.isEmpty(jvmParametersSetup)) { LOG.assertTrue(!jvmParametersSetup.contains(ForkedDebuggerHelper.JVM_DEBUG_SETUP_PREFIX), "Please use org.jetbrains.plugins.gradle.service.debugger.GradleJvmDebuggerBackend to setup debugger"); final String names = "[" + toStringListLiteral(taskNames, ", ") + "]"; List<String> argv = ParametersListUtil.parse(jvmParametersSetup); if (SystemInfo.isWindows) { argv = ContainerUtil.map(argv, s -> CommandLineUtil.escapeParameterOnWindows(s, false)); } final String jvmArgs = toStringListLiteral(argv, " << "); final String[] lines = { "gradle.taskGraph.whenReady { taskGraph ->", " taskGraph.allTasks.each { Task task ->", " if (task instanceof JavaForkOptions && (" + names + ".contains(task.name) || " + names + ".contains(task.path))) {", " def jvmArgs = task.jvmArgs.findAll{!it?.startsWith('-agentlib:jdwp') && !it?.startsWith('-Xrunjdwp')}", " jvmArgs << " + jvmArgs, " task.jvmArgs = jvmArgs", " }", " }", "}", }; final String script = StringUtil.join(lines, System.lineSeparator()); initScriptConsumer.consume(script); } }