Fixed invalid char escaping for release train docs config props generation

This commit is contained in:
Marcin Grzejszczak
2020-11-18 08:23:43 +01:00
parent ac966b7be5
commit dc4cdf3f08

View File

@@ -28,40 +28,32 @@ import org.springframework.util.StringUtils;
class ConfigurationPropertiesAggregator {
private static final List<String> wordsToIgnore = Arrays.asList("|===",
"|Name | Default | Description");
private static final List<String> wordsToIgnore = Arrays.asList("|===", "|Name | Default | Description");
List<ConfigurationProperty> mergedConfigurationProperties(Path unpackedDocs) {
try {
return Files.walk(unpackedDocs)
.filter(path -> path.endsWith("_configprops.adoc")).flatMap(path -> {
try {
return Files.readAllLines(path).stream()
.filter(s -> !StringUtils.isEmpty(s)
&& !wordsToIgnore.contains(s))
.map(s -> {
// |foo|bar|baz -> foo|bar|baz -> split ->
// foo,bar,baz
String[] strings = s.substring(1).split("\\|");
if (strings.length == 3) {
return new ConfigurationProperty(
strings[0].trim(), strings[1].trim(),
strings[2].trim());
}
else if (strings.length == 2) {
return new ConfigurationProperty(
strings[0].trim(), strings[1].trim(),
"");
}
return new ConfigurationProperty(
strings[0].trim(), "", "");
});
}
catch (IOException e) {
throw new IllegalStateException(e);
}
}).sorted(Comparator.comparing(o -> o.name))
.collect(Collectors.toList());
return Files.walk(unpackedDocs).filter(path -> path.endsWith("_configprops.adoc")).flatMap(path -> {
try {
return Files.readAllLines(path).stream()
.filter(s -> !StringUtils.isEmpty(s) && !wordsToIgnore.contains(s)).map(s -> {
// |foo|bar|baz -> foo|bar|baz -> split ->
// foo,bar,baz
String[] strings = s.substring(1).split("\\|");
if (strings.length == 3) {
return new ConfigurationProperty(strings[0].trim(),
strings[1].trim().replace("`", ""), strings[2].trim());
}
else if (strings.length == 2) {
return new ConfigurationProperty(strings[0].trim(),
strings[1].trim().replace("`", ""), "");
}
return new ConfigurationProperty(strings[0].trim(), "", "");
});
}
catch (IOException e) {
throw new IllegalStateException(e);
}
}).sorted(Comparator.comparing(o -> o.name)).collect(Collectors.toList());
}
catch (IOException e) {
throw new IllegalStateException(e);