use of org.apache.maven.shared.filtering.MavenReaderFilterRequest in project maven-plugins by apache.
the class ReaderFormatter method createReaderFilter.
private static Reader createReaderFilter(@Nonnull Reader source, String escapeString, List<String> delimiters, AssemblerConfigurationSource configSource, boolean isPropertiesFile) throws IOException {
try {
MavenReaderFilterRequest filterRequest = new MavenReaderFilterRequest(source, true, configSource.getProject(), configSource.getFilters(), isPropertiesFile, configSource.getMavenSession(), null);
filterRequest.setEscapeString(escapeString);
// if these are NOT set, just use the defaults, which are '${*}' and '@'.
if (delimiters != null && !delimiters.isEmpty()) {
LinkedHashSet<String> delims = new LinkedHashSet<String>();
for (String delim : delimiters) {
if (delim == null) {
// FIXME: ${filter:*} could also trigger this condition. Need a better long-term solution.
delims.add("${*}");
} else {
delims.add(delim);
}
}
filterRequest.setDelimiters(delims);
} else {
filterRequest.setDelimiters(filterRequest.getDelimiters());
}
filterRequest.setInjectProjectBuildFilters(configSource.isIncludeProjectBuildFilters());
return configSource.getMavenReaderFilter().filter(filterRequest);
} catch (MavenFilteringException e) {
IOException ioe = new IOException("Error filtering file '" + source + "': " + e.getMessage());
// plain old Java 5...
ioe.initCause(e);
throw ioe;
}
}
Aggregations