use of org.apache.maven.plugins.assembly.utils.LineEndings in project maven-plugins by apache.
the class ReaderFormatter method getFileSetTransformers.
@Nullable
public static InputStreamTransformer getFileSetTransformers(final AssemblerConfigurationSource configSource, final boolean isFiltered, String fileSetLineEnding) throws AssemblyFormattingException {
final LineEndings lineEndingToUse = LineEndingsUtils.getLineEnding(fileSetLineEnding);
final boolean transformLineEndings = !LineEndings.keep.equals(lineEndingToUse);
if (transformLineEndings || isFiltered) {
return new InputStreamTransformer() {
@Override
@Nonnull
public InputStream transform(@Nonnull PlexusIoResource plexusIoResource, @Nonnull InputStream inputStream) throws IOException {
InputStream result = inputStream;
if (isFiltered) {
boolean isPropertyFile = AssemblyFileUtils.isPropertyFile(plexusIoResource.getName());
final String encoding = isPropertyFile ? "ISO-8859-1" : configSource.getEncoding();
Reader source = encoding != null ? new InputStreamReader(inputStream, encoding) : // wtf platform encoding ? TODO: Fix this
new InputStreamReader(inputStream);
Reader filtered = createReaderFilter(source, configSource.getEscapeString(), configSource.getDelimiters(), configSource, isPropertyFile);
result = encoding != null ? new ReaderInputStream(filtered, encoding) : new ReaderInputStream(filtered);
}
if (transformLineEndings) {
checkifFileTypeIsAppropriateForLineEndingTransformation(plexusIoResource);
result = LineEndingsUtils.lineEndingConverter(result, lineEndingToUse);
}
return result;
}
};
}
return null;
}
Aggregations