Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tools.ant.taskdefs
Class Jar

    java.lang.Object
      org.apache.tools.ant.ProjectComponent
          org.apache.tools.ant.Task
              org.apache.tools.ant.taskdefs.MatchingTask
                  org.apache.tools.ant.taskdefs.Zip
                      org.apache.tools.ant.taskdefs.Jar

All Implemented Interfaces:
  SelectorContainer

Direct Known Subclasses:
  Ear, War

public class Jar
extends Zip

Creates a JAR archive.

Since:
  Ant 1.1
Author:
  James Davidson duncan@x180.com, Brian Deitte bdeitte@macromedia.com

Nested Class Summary
`static class` | `Jar.FilesetManifestConfig`

Nested classes inherited from class org.apache.tools.ant.taskdefs.Zip
`Zip.ArchiveState, Zip.Duplicate, Zip.WhenEmpty`

Field Summary

Fields inherited from class org.apache.tools.ant.taskdefs.Zip
`addedDirs, archiveType, duplicate, emptyBehavior, entries, zipFile`

Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
`fileset, useDefaultExcludes`

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`

Constructor Summary
`Jar()` constructor

Method Summary
`void` | `addConfiguredManifest(Manifest newManifest)` Allows the manifest for the archive file to be provided inline in the build file rather than in an external file.
`void` | `addMetainf(ZipFileSet fs)` Adds a zipfileset to include in the META-INF directory.
`protected void` | `cleanUp()` Make sure we don't think we already have a MANIFEST next time this task gets executed.
`protected boolean` | `createEmptyZip(java.io.File zipFile)` Create an empty zip file
`protected void` | `finalizeZipOutputStream(ZipOutputStream zOut)` method for subclasses to override
`protected Zip.ArchiveState` | `getResourcesToAdd(FileSet[] filesets, java.io.File zipFile, boolean needsUpdate)` Collect the resources that are newer than the corresponding entries (or missing) in the original archive.
`protected void` | `initZipOutputStream(ZipOutputStream zOut)` method for subclasses to override
`void` | `reset()` reset to default values.
`void` | `setIndex(boolean flag)` Set whether or not to create an index list for classes.
`void` | `setJarfile(java.io.File jarFile)` Deprecated. Use setDestFile(File) instead
`void` | `setManifest(java.io.File manifestFile)` The manifest file to use.
`void` | `setManifestEncoding(java.lang.String manifestEncoding)` Set whether or not to create an index list for classes.
`void` | `setWhenempty(Zip.WhenEmpty we)` Sets behavior of the task when no files match.
`protected void` | `zipFile(java.io.InputStream is, ZipOutputStream zOut, java.lang.String vPath, long lastModified, java.io.File fromArchive, int mode)` Overriden from Zip class to deal with manifests

Methods inherited from class org.apache.tools.ant.taskdefs.Zip
`addFileset, addParentDirs, addResources, addZipfileset, addZipGroupFileset, execute, getDestFile, getEncoding, grabResources, isAddingNewFiles, isCompress, isEmpty, isInUpdateMode, setBasedir, setCompress, setDestFile, setDuplicate, setEncoding, setFile, setFilesonly, setUpdate, setZipfile, zipDir, zipFile`

Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask
`addAnd, addContains, addCustom, addDate, addDepend, addDepth, addFilename, addMajority, addNone, addNot, addOr, addPresent, addSelector, addSize, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems`

Methods inherited from class org.apache.tools.ant.Task
`getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorFlush, handleErrorOutput, handleFlush, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName`

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

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Jar

    public Jar()

  constructor

Method Detail

### setWhenempty

    public void setWhenempty(Zip.WhenEmpty we)

  Description copied from class: `Zip`
  Sets behavior of the task when no files match. Possible values are: `fail` (throw an exception and halt the build); `skip` (do not create any archive, but issue a warning); `create` (make an archive with no entries). Default for zip tasks is `skip`; for jar tasks, `create`.

  Overrides:
    `setWhenempty` in class `Zip`

### setJarfile

    public void setJarfile(java.io.File jarFile)

  Deprecated. Use setDestFile(File) instead

### setIndex

    public void setIndex(boolean flag)

  Set whether or not to create an index list for classes. This may speed up classloading in some cases.

### setManifestEncoding

    public void setManifestEncoding(java.lang.String manifestEncoding)

  Set whether or not to create an index list for classes. This may speed up classloading in some cases.

### addConfiguredManifest

    public void addConfiguredManifest(Manifest newManifest)
                               throws ManifestException

  Allows the manifest for the archive file to be provided inline in the build file rather than in an external file.

  Parameters:
    `newManifest` -
  Throws:
    `ManifestException`

### setManifest

    public void setManifest(java.io.File manifestFile)

  The manifest file to use. This can be either the location of a manifest, or the name of a jar added through a fileset. If its the name of an added jar, the task expects the manifest to be in the jar at META-INF/MANIFEST.MF.

  Parameters:
    `manifestFile` - the manifest file to use.

### addMetainf

    public void addMetainf(ZipFileSet fs)

  Adds a zipfileset to include in the META-INF directory.

  Parameters:
    `fs` - zipfileset to add

### initZipOutputStream

    protected void initZipOutputStream(ZipOutputStream zOut)
                                throws java.io.IOException,
                                       BuildException

  Description copied from class: `Zip`
  method for subclasses to override

  Overrides:
    `initZipOutputStream` in class `Zip`
  Throws:
    `java.io.IOException`
    `BuildException`

### finalizeZipOutputStream

    protected void finalizeZipOutputStream(ZipOutputStream zOut)
                                    throws java.io.IOException,
                                           BuildException

  Description copied from class: `Zip`
  method for subclasses to override

  Overrides:
    `finalizeZipOutputStream` in class `Zip`
  Throws:
    `java.io.IOException`
    `BuildException`

### zipFile

    protected void zipFile(java.io.InputStream is,
                           ZipOutputStream zOut,
                           java.lang.String vPath,
                           long lastModified,
                           java.io.File fromArchive,
                           int mode)
                    throws java.io.IOException

  Overriden from Zip class to deal with manifests

  Overrides:
    `zipFile` in class `Zip`
  Parameters:
    `is` - the stream to read data for the entry from.
    `zOut` - the stream to write to.
    `vPath` - the name this entry shall have in the archive.
    `lastModified` - last modification time for the entry.
    `fromArchive` - the original archive we are copying this entry from, will be null if we are not copying from an archive.
    `mode` - the Unix permissions to set.
  Throws:
    `java.io.IOException`

### getResourcesToAdd

    protected Zip.ArchiveState getResourcesToAdd(FileSet[] filesets,
                                                 java.io.File zipFile,
                                                 boolean needsUpdate)
                                          throws BuildException

  Collect the resources that are newer than the corresponding entries (or missing) in the original archive.

  If we are going to recreate the archive instead of updating it, all resources should be considered as new, if a single one is. Because of this, subclasses overriding this method must call `super.getResourcesToAdd` and indicate with the third arg if they already know that the archive is out-of-date.

  Overrides:
    `getResourcesToAdd` in class `Zip`
  Parameters:
    `filesets` - The filesets to grab resources from
    `zipFile` - intended archive file (may or may not exist)
    `needsUpdate` - whether we already know that the archive is out-of-date. Subclasses overriding this method are supposed to set this value correctly in their call to super.getResourcesToAdd.
  Returns:
    an array of resources to add for each fileset passed in as well as a flag that indicates whether the archive is uptodate.
  Throws:
    `BuildException` - if it likes

### createEmptyZip

    protected boolean createEmptyZip(java.io.File zipFile)
                              throws BuildException

  Description copied from class: `Zip`
  Create an empty zip file

  Overrides:
    `createEmptyZip` in class `Zip`
  Returns:
    true for historic reasons
  Throws:
    `BuildException`

### cleanUp

    protected void cleanUp()

  Make sure we don't think we already have a MANIFEST next time this task gets executed.

  Overrides:
    `cleanUp` in class `Zip`
  See Also:
    `Zip.cleanUp()`

### reset

    public void reset()

  reset to default values.

  Overrides:
    `reset` in class `Zip`
  Since:
    1.44, Ant 1.5
  See Also:
    `Zip.reset()`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.