Example 2

Create a Zip archive from the contents of directory hierarchies d1 and d2, ignoring all .svn directories. Both directory hierarchies are stored under the directory ds-1.0 in the Zip file. The archive will be put in the directory d.

JavaScript

noSvnFilter = new SuperParentOrFilter( new EntityNameFilter(".svn"), true).not(); new ZipTF(). addSource( new EntityAndAbsoluteLocation( new DirectoryAndFilter(d1, noSvnFilter), "/ds-1.0")). addSource( new EntityAndAbsoluteLocation( new DirectoryAndFilter(d2, noSvnFilter), "/ds-1.0")). setTarget( new FutureFile(d, "ds-1.0.zip")).run();

Example 3

Create a Zip archive with the sources set in many different ways. The archive will be put in the directory d.

Groovy

import org.entityfs.util.CharSequenceReadableFile import org.schmant.arg.EntityAndAbsoluteLocation import org.schmant.support.FutureFile import org.schmant.task.io.zip.ZipTF def tmpDir = new File(props.getStringValue("java.io.tmpdir")) new ZipTF(). // A file added in the root directory of the Zip archive addSource(new File(tmpDir, "f1")). // The contents of /tmp/d1 directory added under the d1 directory in the // Zip archive addSource( new EntityAndAbsoluteLocation( new File(tmpDir, "d1"), "/d1")). // The contents of the string added as the file /doc/README addSource( new EntityAndAbsoluteLocation( new CharSequenceReadableFile( "This is the contents of the README file."), "/doc/README")). setTarget( new FutureFile(d, "misc.zip")).run();

JavaScript

tmpDir = new File(props.getStringValue("java.io.tmpdir")); new ZipTF(). // A file added in the root directory of the Zip archive addSource(new File(tmpDir, "f1")). // The contents of /tmp/d1 directory added under the d1 directory in the // Zip archive addSource( new EntityAndAbsoluteLocation( new File(tmpDir, "d1"), "/d1")). // The contents of the string added as the file /doc/README addSource( new EntityAndAbsoluteLocation( new CharSequenceReadableFile( "This is the contents of the README file."), "/doc/README")). setTarget( new FutureFile(d, "misc.zip")).run();

JRuby

tmpDir = Java::JavaIo::File.new($props.getStringValue("java.io.tmpdir")) Schmant::ZipTF.new. # A file added in the root directory of the Zip archive addSource(Java::JavaIo::File.new(tmpDir, "f1")). # The contents of /tmp/d1 directory added under the d1 directory in the # Zip archive addSource( Schmant::EntityAndAbsoluteLocation.new( Java::JavaIo::File.new(tmpDir, "d1"), "/d1")). # The contents of the string added as the file /doc/README addSource( Schmant::EntityAndAbsoluteLocation.new( Schmant::CharSequenceReadableFile.new( "This is the contents of the README file."), "/doc/README")). setTarget( Schmant::FutureFile.new($d, "misc.zip")).run

Jython

# Java system properties are available through the props object tmpDir = File(props.getStringValue("java.io.tmpdir")) t = ZipTF() # A file added in the root directory of the Zip archive t.addSource(File(tmpDir, "f1")) # The contents of /tmp/d1 directory added under the d1 directory in the Zip # archive t.addSource( EntityAndAbsoluteLocation( File(tmpDir, "d1"), "/d1")) # The contents of the string added as the file /doc/README t.addSource( EntityAndAbsoluteLocation( CharSequenceReadableFile( "This is the contents of the README file."), \ "/doc/README")) t.setTarget( FutureFile(d, "misc.zip")).run()


* An EntityFS-aware task is implemented using EntityFS. This means that it uses the filter settings of DirectoryView:s and also that it often can work with other file system implementations than File-based, such as the RAM file system.