public void testCreateArchiveWithStreamTransformer() throws IOException { InputStreamTransformer is = new InputStreamTransformer() { @Nonnull public InputStream transform( @Nonnull PlexusIoResource resource, @Nonnull InputStream inputStream) throws IOException { return new BoundedInputStream(inputStream, 3); } }; final ZipArchiver zipArchiver = getZipArchiver(getTestFile("target/output/all3bytes.zip")); File zipFIle = new File("src/test/resources/test.zip"); DefaultArchivedFileSet afs = new DefaultArchivedFileSet(zipFIle); afs.setStreamTransformer(is); afs.setPrefix("azip/"); zipArchiver.addArchivedFileSet(afs); DefaultFileSet dfs = new DefaultFileSet(new File("src/test/resources/mjar179")); dfs.setStreamTransformer(is); dfs.setPrefix("mj179/"); zipArchiver.addFileSet(dfs); PlexusIoFileResourceCollection files = new PlexusIoFileResourceCollection(); files.setBaseDir(new File("src/test/resources")); files.setStreamTransformer(is); files.setPrefix("plexus/"); zipArchiver.addResources(files); zipArchiver.createArchive(); }
@SuppressWarnings("ResultOfMethodCallIgnored") public void testSymlinkFileSet() throws Exception { final File zipFile = getTestFile("target/output/pasymlinks-fileset.zip"); final ZipArchiver zipArchiver = getZipArchiver(zipFile); final DefaultFileSet fs = new DefaultFileSet(); fs.setPrefix("bzz/"); fs.setDirectory(new File("src/test/resources/symlinks/src")); zipArchiver.addFileSet(fs); zipArchiver.createArchive(); final File output = getTestFile("target/output/unzipped/symlFs"); output.mkdirs(); final ZipUnArchiver zipUnArchiver = getZipUnArchiver(zipFile); zipUnArchiver.setDestFile(output); zipUnArchiver.extract(); File symDir = new File(output, "bzz/symDir"); PlexusIoResourceAttributes fa = Java7FileAttributes.uncached(symDir); assertTrue(fa.isSymbolicLink()); }
private org.codehaus.plexus.archiver.FileSet toPlexusFileset( org.apache.maven.model.FileSet mavenFs) { DefaultFileSet plexusFs = new DefaultFileSet(); plexusFs.setDirectory(readDirectory(mavenFs)); plexusFs.setIncludes(mavenFs.getIncludes().toArray(new String[0])); plexusFs.setExcludes(mavenFs.getExcludes().toArray(new String[0])); plexusFs.setUsingDefaultExcludes(false); plexusFs.setIncludingEmptyDirectories(true); return plexusFs; }