Top Description Inners Fields Constructors Methods
org.apache.tools.ant.taskdefs

public Class ManifestTask

extends Task
Class Inheritance
Imports
java.io.File, .IOException, .InputStreamReader, .OutputStreamWriter, .PrintWriter, java.nio.charset.Charset, java.nio.file.Files, org.apache.tools.ant.BuildException, .Project, .Task, org.apache.tools.ant.types.EnumeratedAttribute, org.apache.tools.ant.util.StreamUtils

Creates a manifest file for inclusion in a JAR, Ant task wrapper around Manifest. This task can be used to write a Manifest file, optionally replacing or updating an existing file.
Since
Ant 1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ManifestTask.Mode

Helper class for Manifest's mode attribute.

Field Summary

Modifier and TypeField and Description
private String
encoding

The encoding of the manifest file

private boolean
flattenClassPaths

whether to flatten Class-Path attributes into a single one.

private File
manifestFile

The file to which the manifest should be written when used as a task

private boolean
mergeClassPaths

whether to merge Class-Path attributes.

private ManifestTask.Mode
mode

The mode with which the manifest file is written

private Manifest
nestedManifest

Holds the real data.

public static final String
VALID_ATTRIBUTE_CHARS

Specifies the valid characters which can be used in attribute names.

Inherited from org.apache.tools.ant.Task:
targettaskNametaskTypewrapper

Constructor Summary

AccessConstructor and Description
public
ManifestTask()

Default constructor

Method Summary

Modifier and TypeMethod and Description
public void
addConfiguredAttribute(Manifest.Attribute
the attribute to be added.
attribute
)

Add an attribute to the manifest - it is added to the main section.

public void
addConfiguredSection(Manifest.Section
the manifest section to be added
section
)

Add a section to the manifest

private void
checkAttribute(Manifest.Attribute
The attribute to check
attribute
)

Checks the attribute against the Jar-specification.

public void
execute()

Overrides org.apache.tools.ant.Task.execute.

Create or update the Manifest when used as a task.
public void
setEncoding(String
the manifest file encoding.
encoding
)

The encoding to use for reading in an existing manifest file

public void
setFile(File
the Manifest file to be written
f
)

The name of the manifest file to create/update.

public void
setFlattenAttributes(boolean
boolean
b
)

Whether to flatten multi-valued attributes (i.e. Class-Path) into a single one.

public void
setMergeClassPathAttributes(boolean
boolean
b
)

Whether to merge Class-Path attributes.

public void
setMode(ManifestTask.Mode
the mode value - update or replace.
m
)

Update policy: either "update" or "replace"; default is "replace".

Inherited from org.apache.tools.ant.Task:
bindToOwnergetOwningTargetgetRuntimeConfigurableWrappergetTaskNamegetTaskTypegetWrapperhandleErrorFlushhandleErrorOutputhandleFlushhandleInputhandleOutputinitisInvalidloglogloglogmaybeConfigureperformreconfiguresetOwningTargetsetRuntimeConfigurableWrappersetTaskNamesetTaskType

Field Detail

encodingback to summary
private String encoding

The encoding of the manifest file

flattenClassPathsback to summary
private boolean flattenClassPaths

whether to flatten Class-Path attributes into a single one.

manifestFileback to summary
private File manifestFile

The file to which the manifest should be written when used as a task

mergeClassPathsback to summary
private boolean mergeClassPaths

whether to merge Class-Path attributes.

modeback to summary
private ManifestTask.Mode mode

The mode with which the manifest file is written

nestedManifestback to summary
private Manifest nestedManifest

Holds the real data.

VALID_ATTRIBUTE_CHARSback to summary
public static final String VALID_ATTRIBUTE_CHARS

Specifies the valid characters which can be used in attribute names. abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_

Constructor Detail

ManifestTaskback to summary
public ManifestTask()

Default constructor

Method Detail

addConfiguredAttributeback to summary
public void addConfiguredAttribute(Manifest.Attribute attribute) throws ManifestException

Add an attribute to the manifest - it is added to the main section.

Parameters
attribute:Manifest.Attribute

the attribute to be added.

Exceptions
ManifestException:
if the attribute is not valid.
addConfiguredSectionback to summary
public void addConfiguredSection(Manifest.Section section) throws ManifestException

Add a section to the manifest

Parameters
section:Manifest.Section

the manifest section to be added

Exceptions
ManifestException:
if the section is not valid.
checkAttributeback to summary
private void checkAttribute(Manifest.Attribute attribute) throws BuildException

Checks the attribute against the Jar-specification. Jar-Specification "Name-Value pairs and Sections":

  name:       alphanum *headerchar
  alphanum:   {A-Z} | {a-z} | {0-9}
  headerchar: alphanum | - | _
So the resulting regexp would be [A-Za-z0-9][A-Za-z0-9-_]*. Because of JDK 1.2 compliance and the possible absence of a regexp matcher we can not use regexps here. Instead we have to check each character.
Parameters
attribute:Manifest.Attribute

The attribute to check

Exceptions
BuildException:
if the check fails
executeback to summary
public void execute() throws BuildException

Overrides org.apache.tools.ant.Task.execute.

Create or update the Manifest when used as a task.

Annotations
@Override
Exceptions
BuildException:
if the manifest cannot be written.
setEncodingback to summary
public void setEncoding(String encoding)

The encoding to use for reading in an existing manifest file

Parameters
encoding:String

the manifest file encoding.

setFileback to summary
public void setFile(File f)

The name of the manifest file to create/update. Required if used as a task.

Parameters
f:File

the Manifest file to be written

setFlattenAttributesback to summary
public void setFlattenAttributes(boolean b)

Whether to flatten multi-valued attributes (i.e. Class-Path) into a single one.

Parameters
b:boolean

boolean

Since
Ant 1.8.0
setMergeClassPathAttributesback to summary
public void setMergeClassPathAttributes(boolean b)

Whether to merge Class-Path attributes.

Parameters
b:boolean

boolean

Since
Ant 1.8.0
setModeback to summary
public void setMode(ManifestTask.Mode m)

Update policy: either "update" or "replace"; default is "replace".

Parameters
m:ManifestTask.Mode

the mode value - update or replace.

org.apache.tools.ant.taskdefs back to summary

public Class ManifestTask.Mode

extends EnumeratedAttribute
Class Inheritance

Helper class for Manifest's mode attribute.

Field Summary

Inherited from org.apache.tools.ant.types.EnumeratedAttribute:
value

Constructor Summary

AccessConstructor and Description
public
Mode()

Method Summary

Modifier and TypeMethod and Description
public String[]

Returns:

a String array of the allowed values.
getValues
()

Implements abstract org.apache.tools.ant.types.EnumeratedAttribute.getValues.

Get Allowed values for the mode attribute.
Inherited from org.apache.tools.ant.types.EnumeratedAttribute:
containsValuegetIndexgetInstancegetValueindexOfValuesetValuetoString

Constructor Detail

Modeback to summary
public Mode()

Method Detail

getValuesback to summary
public String[] getValues()

Implements abstract org.apache.tools.ant.types.EnumeratedAttribute.getValues.

Get Allowed values for the mode attribute.

Returns:String[]

a String array of the allowed values.

Annotations
@Override