org.apache.tools.ant.taskdefs

Class Tar

Implemented Interfaces:
SelectorContainer

public class Tar
extends MatchingTask

Creates a tar archive.
Since:
Ant 1.1

Nested Class Summary

static class
Tar.TarCompressionMethod
Valid Modes for Compression attribute to Tar Task
static class
Tar.TarFileSet
This is a FileSet with the option to specify permissions and other attributes.
static class
Tar.TarLongFileMode
Set of options for long file handling in the task.

Field Summary

static String
FAIL
Deprecated. Tar.FAIL is deprecated and is replaced with Tar.TarLongFileMode.FAIL
static String
GNU
Deprecated. Tar.GNU is deprecated and is replaced with Tar.TarLongFileMode.GNU
static String
OMIT
Deprecated. Tar.OMIT is deprecated and is replaced with Tar.TarLongFileMode.OMIT
static String
TRUNCATE
Deprecated. Tar.TRUNCATE is deprecated and is replaced with Tar.TarLongFileMode.TRUNCATE
static String
WARN
Deprecated. Tar.WARN is deprecated and is replaced with Tar.TarLongFileMode.WARN

Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask

fileset

Fields inherited from class org.apache.tools.ant.Task

description, location, target, taskName, taskType, wrapper

Fields inherited from class org.apache.tools.ant.ProjectComponent

project

Method Summary

protected boolean
archiveIsUpToDate(String[] files)
Deprecated. use the two-arg version instead.
protected boolean
archiveIsUpToDate(String[] files, File dir)
Is the archive up to date in relationship to a list of files.
Tar.TarFileSet
createTarFileSet()
Add a new fileset with the option to specify permissions
void
execute()
do the business
void
setBasedir(File baseDir)
This is the base directory to look in for things to tar.
void
setCompression(Tar.TarCompressionMethod mode)
Set compression method.
void
setDestFile(File destFile)
Set is the name/location of where to create the tar file.
void
setLongfile(String mode)
Deprecated. setLongFile(String) is deprecated and is replaced with setLongFile(Tar.TarLongFileMode) to make Ant's Introspection mechanism do the work and also to encapsulate operations on the mode in its own class.
void
setLongfile(Tar.TarLongFileMode mode)
Set how to handle long files, those with a path>100 chars.
void
setTarfile(File tarFile)
Deprecated. for consistency with other tasks, please use setDestFile()
protected void
tarFile(File file, TarOutputStream tOut, String vPath, Tar.TarFileSet tarFileSet)
tar a file

Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask

XsetIgnore, XsetItems, add, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject

Methods inherited from class org.apache.tools.ant.Task

execute, getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType

Methods inherited from class org.apache.tools.ant.ProjectComponent

getProject, log, log, setProject

Field Details

FAIL

public static final String FAIL

Deprecated. Tar.FAIL is deprecated and is replaced with Tar.TarLongFileMode.FAIL


GNU

public static final String GNU

Deprecated. Tar.GNU is deprecated and is replaced with Tar.TarLongFileMode.GNU


OMIT

public static final String OMIT

Deprecated. Tar.OMIT is deprecated and is replaced with Tar.TarLongFileMode.OMIT


TRUNCATE

public static final String TRUNCATE

Deprecated. Tar.TRUNCATE is deprecated and is replaced with Tar.TarLongFileMode.TRUNCATE


WARN

public static final String WARN

Deprecated. Tar.WARN is deprecated and is replaced with Tar.TarLongFileMode.WARN

Method Details

archiveIsUpToDate

protected boolean archiveIsUpToDate(String[] files)

Deprecated. use the two-arg version instead.

Is the archive up to date in relationship to a list of files.
Parameters:
files - the files to check
Returns:
true if the archive is up to date.

archiveIsUpToDate

protected boolean archiveIsUpToDate(String[] files,
                                    File dir)
Is the archive up to date in relationship to a list of files.
Parameters:
files - the files to check
dir - the base directory for the files.
Returns:
true if the archive is up to date.
Since:
Ant 1.5.2

createTarFileSet

public Tar.TarFileSet createTarFileSet()
Add a new fileset with the option to specify permissions
Returns:
the tar fileset to be used as the nested element.

execute

public void execute()
            throws BuildException
do the business
Overrides:
execute in interface Task
Throws:
BuildException - on error

setBasedir

public void setBasedir(File baseDir)
This is the base directory to look in for things to tar.
Parameters:
baseDir - the base directory.

setCompression

public void setCompression(Tar.TarCompressionMethod mode)
Set compression method. Allowable values are
  • none - no compression
  • gzip - Gzip compression
  • bzip2 - Bzip2 compression
Parameters:
mode - the compression method.

setDestFile

public void setDestFile(File destFile)
Set is the name/location of where to create the tar file.
Parameters:
destFile - The output of the tar
Since:
Ant 1.5

setLongfile

public void setLongfile(String mode)

Deprecated. setLongFile(String) is deprecated and is replaced with setLongFile(Tar.TarLongFileMode) to make Ant's Introspection mechanism do the work and also to encapsulate operations on the mode in its own class.

Set how to handle long files, those with a path>100 chars. Optional, default=warn.

Allowable values are

  • truncate - paths are truncated to the maximum length
  • fail - paths greater than the maximum cause a build exception
  • warn - paths greater than the maximum cause a warning and GNU is used
  • gnu - GNU extensions are used for any paths greater than the maximum.
  • omit - paths greater than the maximum are omitted from the archive
Parameters:
mode - the mode string to handle long files.

setLongfile

public void setLongfile(Tar.TarLongFileMode mode)
Set how to handle long files, those with a path>100 chars. Optional, default=warn.

Allowable values are

  • truncate - paths are truncated to the maximum length
  • fail - paths greater than the maximum cause a build exception
  • warn - paths greater than the maximum cause a warning and GNU is used
  • gnu - GNU extensions are used for any paths greater than the maximum.
  • omit - paths greater than the maximum are omitted from the archive
Parameters:
mode - the mode to handle long file names.

setTarfile

public void setTarfile(File tarFile)

Deprecated. for consistency with other tasks, please use setDestFile()

Set is the name/location of where to create the tar file.
Parameters:
tarFile - the location of the tar file.

tarFile

protected void tarFile(File file,
                       TarOutputStream tOut,
                       String vPath,
                       Tar.TarFileSet tarFileSet)
            throws IOException
tar a file
Parameters:
file - the file to tar
tOut - the output stream
vPath - the path name of the file to tar
tarFileSet - the fileset that the file came from.

Copyright B) 2000-2007 Apache Software Foundation. All Rights Reserved.