| org.apache.tools.ant.taskdefs.MatchingTask org.apache.tools.ant.taskdefs.Zip org.apache.tools.ant.taskdefs.Jar
All known Subclasses: org.apache.tools.ant.taskdefs.Ear, org.apache.tools.ant.taskdefs.War,
Jar | public class Jar extends Zip (Code) | | Creates a JAR archive.
since: Ant 1.1 |
Constructor Summary | |
public | Jar() |
Method Summary | |
public void | addConfiguredIndexJars(Path p) Add a path to index jars. | public 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. | public void | addConfiguredService(Service service) A nested SPI service element. | public 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(File zipFile) Create an empty jar file. | protected void | finalizeZipOutputStream(ZipOutputStream zOut) Finalize the zip output stream. | final protected static String | findJarName(String fileName, String[] classpath) try to guess the name of the given file.
If this jar has a classpath attribute in its manifest, we
can assume that it will only require an index of jars listed
there. | protected ArchiveState | getResourcesToAdd(ResourceCollection[] rcs, File zipFile, boolean needsUpdate) 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. | final protected static void | grabFilesAndDirs(String file, List dirs, List files) Grab lists of all root-level files and all directories
contained in the given archive. | protected void | initZipOutputStream(ZipOutputStream zOut) Initialize the zip output stream. | public void | reset() reset to default values. | public void | setFilesetmanifest(FilesetManifestConfig config) Behavior when a Manifest is found in a zipfileset or zipgroupfileset file. | public void | setIndex(boolean flag) Set whether or not to create an index list for classes. | public void | setJarfile(File jarFile) Set the destination file. | public void | setManifest(File manifestFile) The manifest file to use. | public void | setManifestEncoding(String manifestEncoding) The character encoding to use in the manifest file. | public void | setWhenempty(WhenEmpty we) Not used for jar files. | public void | setWhenmanifestonly(WhenEmpty we) Indicates if a jar file should be created when it would only contain a
manifest file. | final protected void | writeIndexLikeList(List dirs, List files, PrintWriter writer) Writes the directory entries from the first and the filenames
from the second list to the given writer, one entry per line. | protected void | zipFile(InputStream is, ZipOutputStream zOut, String vPath, long lastModified, File fromArchive, int mode) Overridden from Zip class to deal with manifests and index lists. |
Jar | public Jar()(Code) | | constructor
|
addConfiguredIndexJars | public void addConfiguredIndexJars(Path p)(Code) | | Add a path to index jars.
Parameters: p - a path since: Ant 1.6.2 |
addConfiguredManifest | public void addConfiguredManifest(Manifest newManifest) throws ManifestException(Code) | | Allows the manifest for the archive file to be provided inline
in the build file rather than in an external file.
Parameters: newManifest - an embedded manifest element throws: ManifestException - on error |
addConfiguredService | public void addConfiguredService(Service service)(Code) | | A nested SPI service element.
Parameters: service - the nested element. since: Ant 1.7 |
addMetainf | public void addMetainf(ZipFileSet fs)(Code) | | Adds a zipfileset to include in the META-INF directory.
Parameters: fs - zipfileset to add |
cleanUp | protected void cleanUp()(Code) | | Make sure we don't think we already have a MANIFEST next time this task
gets executed.
See Also: Zip.cleanUp |
createEmptyZip | protected boolean createEmptyZip(File zipFile) throws BuildException(Code) | | Create an empty jar file.
Parameters: zipFile - the file to create true for historic reasons throws: BuildException - on error |
findJarName | final protected static String findJarName(String fileName, String[] classpath)(Code) | | try to guess the name of the given file.
If this jar has a classpath attribute in its manifest, we
can assume that it will only require an index of jars listed
there. try to find which classpath entry is most likely the
one the given file name points to.
In the absence of a classpath attribute, assume the other
files will be placed inside the same directory as this jar and
use their basename.
if there is a classpath and the given file doesn't match any
of its entries, return null.
Parameters: fileName - the name to look for Parameters: classpath - the classpath to look in (may be null) the matching entry, or null if the file is not found since: Ant 1.6.2 |
getResourcesToAdd | protected ArchiveState getResourcesToAdd(ResourceCollection[] rcs, File zipFile, boolean needsUpdate) throws BuildException(Code) | | 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.
Parameters: rcs - The resource collections to grab resources from Parameters: zipFile - intended archive file (may or may not exist) Parameters: needsUpdate - whether we already know that the archive isout-of-date. Subclasses overriding this method are supposed toset this value correctly in their call tosuper.getResourcesToAdd. an array of resources to add for each fileset passed in as wellas a flag that indicates whether the archive is uptodate. exception: BuildException - if it likes |
grabFilesAndDirs | final protected static void grabFilesAndDirs(String file, List dirs, List files) throws IOException(Code) | | Grab lists of all root-level files and all directories
contained in the given archive.
Parameters: file - the zip file to examine Parameters: dirs - where to place the directories found Parameters: files - where to place the files found since: Ant 1.7 throws: IOException - on error |
reset | public void reset()(Code) | | reset to default values.
See Also: Zip.reset since: 1.44, Ant 1.5 |
setFilesetmanifest | public void setFilesetmanifest(FilesetManifestConfig config)(Code) | | Behavior when a Manifest is found in a zipfileset or zipgroupfileset file.
Valid values are "skip", "merge", and "mergewithoutmain".
"merge" will merge all of manifests together, and merge this into any
other specified manifests.
"mergewithoutmain" merges everything but the Main section of the manifests.
Default value is "skip".
Note: if this attribute's value is not "skip", the created jar will not
be readable by using java.util.jar.JarInputStream
Parameters: config - setting for found manifest behavior. |
setIndex | public void setIndex(boolean flag)(Code) | | Set whether or not to create an index list for classes.
This may speed up classloading in some cases.
Parameters: flag - a boolean value |
setJarfile | public void setJarfile(File jarFile)(Code) | | Set the destination file.
Parameters: jarFile - the destination file |
setManifest | public void setManifest(File manifestFile)(Code) | | 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. |
setManifestEncoding | public void setManifestEncoding(String manifestEncoding)(Code) | | The character encoding to use in the manifest file.
Parameters: manifestEncoding - the character encoding |
setWhenempty | public void setWhenempty(WhenEmpty we)(Code) | | Not used for jar files.
Parameters: we - not used |
setWhenmanifestonly | public void setWhenmanifestonly(WhenEmpty we)(Code) | | Indicates if a jar file should be created when it would only contain a
manifest file.
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 only a manifest file).
Default is create ;
Parameters: we - a WhenEmpty enumerated value |
writeIndexLikeList | final protected void writeIndexLikeList(List dirs, List files, PrintWriter writer) throws IOException(Code) | | Writes the directory entries from the first and the filenames
from the second list to the given writer, one entry per line.
Parameters: dirs - a list of directories Parameters: files - a list of files Parameters: writer - the writer to write to throws: IOException - on error since: Ant 1.6.2 |
zipFile | protected void zipFile(InputStream is, ZipOutputStream zOut, String vPath, long lastModified, File fromArchive, int mode) throws IOException(Code) | | Overridden from Zip class to deal with manifests and index lists.
Parameters: is - the input stream Parameters: zOut - the zip output stream Parameters: vPath - the name this entry shall have in the archive Parameters: lastModified - last modification time for the entry. Parameters: fromArchive - the original archive we are copying thisentry from, will be null if we are not copying from an archive. Parameters: mode - the Unix permissions to set. throws: IOException - on error |
Methods inherited from org.apache.tools.ant.taskdefs.Zip | public void add(ResourceCollection a)(Code)(Java Doc) public void addFileset(FileSet set)(Code)(Java Doc) final protected void addParentDirs(File baseDir, String entry, ZipOutputStream zOut, String prefix, int dirMode) throws IOException(Code)(Java Doc) final protected void addResources(FileSet fileset, Resource[] resources, ZipOutputStream zOut) throws IOException(Code)(Java Doc) final protected void addResources(ResourceCollection rc, Resource[] resources, ZipOutputStream zOut) throws IOException(Code)(Java Doc) public void addZipGroupFileset(FileSet set)(Code)(Java Doc) public void addZipfileset(ZipFileSet set)(Code)(Java Doc) protected void cleanUp()(Code)(Java Doc) protected boolean createEmptyZip(File zipFile) throws BuildException(Code)(Java Doc) public void execute() throws BuildException(Code)(Java Doc) public void executeMain() throws BuildException(Code)(Java Doc) protected void finalizeZipOutputStream(ZipOutputStream zOut) throws IOException, BuildException(Code)(Java Doc) public String getComment()(Code)(Java Doc) public File getDestFile()(Code)(Java Doc) public String getEncoding()(Code)(Java Doc) public int getLevel()(Code)(Java Doc) protected ArchiveState getNonFileSetResourcesToAdd(ResourceCollection[] rcs, File zipFile, boolean needsUpdate) throws BuildException(Code)(Java Doc) protected ArchiveState getResourcesToAdd(ResourceCollection[] rcs, File zipFile, boolean needsUpdate) throws BuildException(Code)(Java Doc) protected ArchiveState getResourcesToAdd(FileSet[] filesets, File zipFile, boolean needsUpdate) throws BuildException(Code)(Java Doc) protected Resource[][] grabNonFileSetResources(ResourceCollection[] rcs)(Code)(Java Doc) protected Resource[][] grabResources(FileSet[] filesets)(Code)(Java Doc) protected void initZipOutputStream(ZipOutputStream zOut) throws IOException, BuildException(Code)(Java Doc) final protected boolean isAddingNewFiles()(Code)(Java Doc) public boolean isCompress()(Code)(Java Doc) final protected static boolean isEmpty(Resource[][] r)(Code)(Java Doc) public boolean isInUpdateMode()(Code)(Java Doc) public void reset()(Code)(Java Doc) protected Resource[] selectFileResources(Resource[] orig)(Code)(Java Doc) public void setBasedir(File baseDir)(Code)(Java Doc) public void setComment(String comment)(Code)(Java Doc) public void setCompress(boolean c)(Code)(Java Doc) public void setDestFile(File destFile)(Code)(Java Doc) public void setDuplicate(Duplicate df)(Code)(Java Doc) public void setEncoding(String encoding)(Code)(Java Doc) public void setFile(File file)(Code)(Java Doc) public void setFilesonly(boolean f)(Code)(Java Doc) public void setKeepCompression(boolean keep)(Code)(Java Doc) public void setLevel(int level)(Code)(Java Doc) public void setRoundUp(boolean r)(Code)(Java Doc) public void setUpdate(boolean c)(Code)(Java Doc) public void setWhenempty(WhenEmpty we)(Code)(Java Doc) public void setZipfile(File zipFile)(Code)(Java Doc) protected void zipDir(File dir, ZipOutputStream zOut, String vPath, int mode) throws IOException(Code)(Java Doc) protected void zipDir(File dir, ZipOutputStream zOut, String vPath, int mode, ZipExtraField[] extra) throws IOException(Code)(Java Doc) protected void zipFile(InputStream in, ZipOutputStream zOut, String vPath, long lastModified, File fromArchive, int mode) throws IOException(Code)(Java Doc) protected void zipFile(File file, ZipOutputStream zOut, String vPath, int mode) throws IOException(Code)(Java Doc)
|
|
|