Search in sources :

Example 1 with MavenReaderFilterRequest

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;
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) MavenReaderFilterRequest(org.apache.maven.shared.filtering.MavenReaderFilterRequest) MavenFilteringException(org.apache.maven.shared.filtering.MavenFilteringException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 LinkedHashSet (java.util.LinkedHashSet)1 MavenFilteringException (org.apache.maven.shared.filtering.MavenFilteringException)1 MavenReaderFilterRequest (org.apache.maven.shared.filtering.MavenReaderFilterRequest)1