@Test public void lineUnixFeedWithInterpolation() throws IOException, AssemblyFormattingException { final PojoConfigSource cfg = getPojoConfigSource(); InputStreamTransformer fileSetTransformers = ReaderFormatter.getFileSetTransformers( cfg, true, "unix" ); InputStream fud = fileSetTransformers.transform( dummyResource(), payload( "This is a test for project: ${artifactId} @artifactId@." ) ); assertEquals( "This is a test for project: anArtifact anArtifact.", readResultStream( fud ) ); }
@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 ) : 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; }
ReaderFormatter { @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 ) : 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; } }
ReaderFormatter { @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 ) : 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; }  }
ReaderFormatter { @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 ) : 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; }  @Nullable static InputStreamTransformer getFileSetTransformers( final AssemblerConfigurationSource configSource,
                                                                 final boolean isFiltered, String fileSetLineEnding ); }
ReaderFormatter { @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 ) : 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; }  @Nullable static InputStreamTransformer getFileSetTransformers( final AssemblerConfigurationSource configSource,
                                                                 final boolean isFiltered, String fileSetLineEnding );  }