in src/main/java/org/apache/sling/cli/impl/jbake/JBakeContentUpdater.java [35:61]
public int updateDownloads(Path downloadsTemplatePath, String newReleaseName, String newReleaseVersion) throws IOException {
int[] changeCount = new int[1];
List<String> updatedLines = Files.readAllLines(downloadsTemplatePath, StandardCharsets.UTF_8).stream()
.map(line -> {
Matcher matcher = DOWNLOAD_LINE_PATTERN.matcher(line);
if ( !matcher.find() )
return line;
if ( ! matcher.group(1).equals(newReleaseName) )
return line;
changeCount[0]++;
StringBuilder buffer = new StringBuilder();
buffer.append(line.substring(0, matcher.start(3)));
buffer.append(newReleaseVersion);
buffer.append(line.substring(matcher.end(3)));
return buffer.toString();
}).collect(Collectors.toList());
Files.write(downloadsTemplatePath, updatedLines);
return changeCount[0];
}