|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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
public class Jar
Creates a JAR archive.
Nested Class Summary | |
---|---|
static class |
Jar.FilesetManifestConfig
The manifest config enumerated type. |
Nested classes/interfaces inherited from class org.apache.tools.ant.taskdefs.Zip |
---|
Zip.ArchiveState, Zip.Duplicate, Zip.WhenEmpty |
Field Summary | |
---|---|
protected java.lang.String |
emptyBehavior
|
Fields inherited from class org.apache.tools.ant.taskdefs.Zip |
---|
addedDirs, archiveType, doubleFilePass, duplicate, entries, skipWriting, zipFile |
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask |
---|
fileset |
Fields inherited from class org.apache.tools.ant.Task |
---|
target, taskName, taskType, wrapper |
Fields inherited from class org.apache.tools.ant.ProjectComponent |
---|
description, location, project |
Constructor Summary | |
---|---|
Jar()
constructor |
Method Summary | |
---|---|
void |
addConfiguredIndexJars(Path p)
Add a path to index jars. |
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 |
addConfiguredService(Service service)
A nested SPI service element. |
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 jar file. |
protected void |
finalizeZipOutputStream(ZipOutputStream zOut)
Finalize the zip output stream. |
protected static java.lang.String |
findJarName(java.lang.String fileName,
java.lang.String[] classpath)
try to guess the name of the given file. |
protected Zip.ArchiveState |
getResourcesToAdd(ResourceCollection[] rcs,
java.io.File zipFile,
boolean needsUpdate)
Collect the resources that are newer than the corresponding entries (or missing) in the original archive. |
protected static void |
grabFilesAndDirs(java.lang.String file,
java.util.List dirs,
java.util.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. |
void |
reset()
reset to default values. |
void |
setFilesetmanifest(Jar.FilesetManifestConfig config)
Behavior when a Manifest is found in a zipfileset or zipgroupfileset file. |
void |
setIndex(boolean flag)
Set whether or not to create an index list for classes. |
void |
setJarfile(java.io.File jarFile)
Deprecated. since 1.5.x. Use setDestFile(File) instead. |
void |
setManifest(java.io.File manifestFile)
The manifest file to use. |
void |
setManifestEncoding(java.lang.String manifestEncoding)
The character encoding to use in the manifest file. |
void |
setWhenempty(Zip.WhenEmpty we)
Not used for jar files. |
void |
setWhenmanifestonly(Zip.WhenEmpty we)
Indicates if a jar file should be created when it would only contain a manifest file. |
protected void |
writeIndexLikeList(java.util.List dirs,
java.util.List files,
java.io.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(java.io.InputStream is,
ZipOutputStream zOut,
java.lang.String vPath,
long lastModified,
java.io.File fromArchive,
int mode)
Overridden from Zip class to deal with manifests and index lists. |
Methods inherited from class org.apache.tools.ant.taskdefs.Zip |
---|
add, addFileset, addParentDirs, addResources, addResources, addZipfileset, addZipGroupFileset, execute, executeMain, getComment, getDestFile, getEncoding, getLevel, getNonFileSetResourcesToAdd, getResourcesToAdd, grabNonFileSetResources, grabResources, isAddingNewFiles, isCompress, isEmpty, isInUpdateMode, selectFileResources, setBasedir, setComment, setCompress, setDestFile, setDuplicate, setEncoding, setFile, setFilesonly, setKeepCompression, setLevel, setRoundUp, setUpdate, setZipfile, zipDir, zipDir, zipFile |
Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask |
---|
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, XsetIgnore, XsetItems |
Methods inherited from class org.apache.tools.ant.Task |
---|
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType |
Methods inherited from class org.apache.tools.ant.ProjectComponent |
---|
clone, getDescription, getLocation, getProject, setDescription, setLocation |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String emptyBehavior
Constructor Detail |
---|
public Jar()
Method Detail |
---|
public void setWhenempty(Zip.WhenEmpty we)
setWhenempty
in class Zip
we
- not usedpublic void setWhenmanifestonly(Zip.WhenEmpty we)
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
;
we
- a WhenEmpty
enumerated valuepublic void setJarfile(java.io.File jarFile)
jarFile
- the destination filepublic void setIndex(boolean flag)
flag
- a boolean
valuepublic void setManifestEncoding(java.lang.String manifestEncoding)
manifestEncoding
- the character encodingpublic void addConfiguredManifest(Manifest newManifest) throws ManifestException
newManifest
- an embedded manifest element
ManifestException
- on errorpublic void setManifest(java.io.File manifestFile)
manifestFile
- the manifest file to use.public void setFilesetmanifest(Jar.FilesetManifestConfig config)
config
- setting for found manifest behavior.public void addMetainf(ZipFileSet fs)
fs
- zipfileset to addpublic void addConfiguredIndexJars(Path p)
p
- a pathpublic void addConfiguredService(Service service)
service
- the nested element.protected void initZipOutputStream(ZipOutputStream zOut) throws java.io.IOException, BuildException
initZipOutputStream
in class Zip
zOut
- the zip output stream
java.io.IOException
- on I/O errors
BuildException
- on other errorsprotected void finalizeZipOutputStream(ZipOutputStream zOut) throws java.io.IOException, BuildException
finalizeZipOutputStream
in class Zip
zOut
- the zip output stream
java.io.IOException
- on I/O errors
BuildException
- on other errorsprotected void zipFile(java.io.InputStream is, ZipOutputStream zOut, java.lang.String vPath, long lastModified, java.io.File fromArchive, int mode) throws java.io.IOException
zipFile
in class Zip
is
- the input streamzOut
- the zip output streamvPath
- the name this entry shall have in the archivelastModified
- 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.
java.io.IOException
- on errorprotected Zip.ArchiveState getResourcesToAdd(ResourceCollection[] rcs, java.io.File zipFile, boolean needsUpdate) throws BuildException
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.
getResourcesToAdd
in class Zip
rcs
- The resource collections to grab resources fromzipFile
- 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.
BuildException
- if it likesprotected boolean createEmptyZip(java.io.File zipFile) throws BuildException
createEmptyZip
in class Zip
zipFile
- the file to create
BuildException
- on errorprotected void cleanUp()
cleanUp
in class Zip
Zip.cleanUp()
public void reset()
reset
in class Zip
Zip.reset()
protected final void writeIndexLikeList(java.util.List dirs, java.util.List files, java.io.PrintWriter writer) throws java.io.IOException
dirs
- a list of directoriesfiles
- a list of fileswriter
- the writer to write to
java.io.IOException
- on errorprotected static final java.lang.String findJarName(java.lang.String fileName, java.lang.String[] classpath)
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.
fileName
- the name to look forclasspath
- the classpath to look in (may be null)
protected static final void grabFilesAndDirs(java.lang.String file, java.util.List dirs, java.util.List files) throws java.io.IOException
file
- the zip file to examinedirs
- where to place the directories foundfiles
- where to place the files found
java.io.IOException
- on error
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |