String (@NotNull String originalText, @NotNull String vmOptions) { Matcher matcher = VM_OPTIONS_REGEX.matcher(originalText); StringBuilder result = new StringBuilder(originalText.length() + vmOptions.length()); String escapedValue = StringUtil.escapeProperty(vmOptions, false); if (matcher.find()) { matcher.appendReplacement(result, "$1" + Matcher.quoteReplacement(escapedValue) + "$2"); matcher.appendTail(result); } else { result.append(originalText); if (!originalText.isEmpty() && !originalText.endsWith("\n")) result.append("\n"); result.append("org.gradle.jvmargs=").append(escapedValue).append("\n"); } return result.toString(); }