use of org.apache.commons.text.io.StringSubstitutorReader in project jib by google.
the class BuildFiles method toBuildFileSpec.
/**
* Read a build file from disk and apply templating parameters.
*/
private static BuildFileSpec toBuildFileSpec(Path buildFilePath, Map<String, String> templateParameters) throws IOException {
ObjectMapper yamlObjectMapper = new ObjectMapper(new YAMLFactory());
StringSubstitutor templater = new StringSubstitutor(templateParameters).setEnableUndefinedVariableException(true);
try (StringSubstitutorReader reader = new StringSubstitutorReader(Files.newBufferedReader(buildFilePath, Charsets.UTF_8), templater)) {
return yamlObjectMapper.readValue(reader, BuildFileSpec.class);
}
}
Aggregations