Top Description Fields Constructors Methods
org.apache.tools.ant.taskdefs.optional.extension

public final Class JarLibManifestTask

extends Task
Class Inheritance
Imports
java.io.File, .IOException, .OutputStream, java.nio.file.Files, java.util.ArrayList, .List, java.util.jar.Attributes, .Manifest, java.util.stream.Collectors, .IntStream, .Stream, org.apache.tools.ant.BuildException, .MagicNames, .Project, .Task

Generates a manifest that declares all the dependencies. The dependencies are determined by looking in the specified path and searching for Extension / "Optional Package" specifications in the manifests of the jars.

Prior to JDK1.3, an "Optional Package" was known as an Extension. The specification for this mechanism is available in the JDK1.3 documentation in the directory $JDK_HOME/docs/guide/extensions/versioning.html. Alternatively it is available online at https://docs.oracle.com/javase/8/docs/technotes/guides/extensions/versioning.html.

Field Summary

Modifier and TypeField and Description
private static final String
CREATED_BY

"Created-By" string used when creating manifest.

private final List<ExtensionSet>
dependencies

ExtensionAdapter objects representing dependencies required by library.

private File
destFile

The library to display information about.

private Extension
extension

The extension supported by this library (if any).

private final List<ExtraAttribute>
extraAttributes

Extra attributes the user specifies for main section in manifest.

private static final String
MANIFEST_VERSION

Version of manifest spec that task generates.

private final List<ExtensionSet>
optionals

ExtensionAdapter objects representing optional dependencies required by library.

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

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addConfiguredAttribute(final ExtraAttribute
an attribute that is to be put in main section of manifest.
attribute
)

Adds an attribute that is to be put in main section of manifest.

public void
addConfiguredDepends(final ExtensionSet
a set of extensions that this library requires.
extensionSet
)

Adds a set of extensions that this library requires.

public void
addConfiguredExtension(final ExtensionAdapter
an extension that this library implements.
extensionAdapter
)

Adds an extension that this library implements.

public void
addConfiguredOptions(final ExtensionSet
a set of extensions that this library optionally requires.
extensionSet
)

Adds a set of extensions that this library optionally requires.

private void
appendExtensionList(final Attributes
the attributes to add key-value to
attributes
,
final Attributes.Name
the key to use
extensionKey
,
final String
the prefix for all libraries
listPrefix
,
final int
the number of libraries to list
size
)

Append an attribute such as "Extension-List: lib0 lib1 lib2" using specified prefix and counting up to specified size.

private void
appendExtraAttributes(final Attributes
the manifest section to write attributes to
attributes
)

Add any extra attributes to the manifest.

private void
appendLibraryList(final Attributes
the attributes to add extensions to
attributes
,
final String listPrefix, final List<Extension>
the list of extensions
extensions
)

Append specified extensions to specified attributes.

public void
execute()

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

Execute the task.
public void
setDestfile(final File
The location where generated manifest is placed.
destFile
)

The location where generated manifest is placed.

private List<Extension>
toExtensions(final List<ExtensionSet>
the list of ExtensionSets to add to list
extensionSets
)

Convert a list of ExtensionSet objects to extensions.

private void
validate()

Validate the tasks parameters.

private void
writeManifest(final Manifest
the manifest
manifest
)

Write out manifest to destfile.

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

Field Detail

CREATED_BYback to summary
private static final String CREATED_BY

"Created-By" string used when creating manifest.

dependenciesback to summary
private final List<ExtensionSet> dependencies

ExtensionAdapter objects representing dependencies required by library.

destFileback to summary
private File destFile

The library to display information about.

extensionback to summary
private Extension extension

The extension supported by this library (if any).

extraAttributesback to summary
private final List<ExtraAttribute> extraAttributes

Extra attributes the user specifies for main section in manifest.

MANIFEST_VERSIONback to summary
private static final String MANIFEST_VERSION

Version of manifest spec that task generates.

optionalsback to summary
private final List<ExtensionSet> optionals

ExtensionAdapter objects representing optional dependencies required by library.

Constructor Detail

JarLibManifestTaskback to summary
public JarLibManifestTask()

Method Detail

addConfiguredAttributeback to summary
public void addConfiguredAttribute(final ExtraAttribute attribute)

Adds an attribute that is to be put in main section of manifest.

Parameters
attribute:ExtraAttribute

an attribute that is to be put in main section of manifest.

addConfiguredDependsback to summary
public void addConfiguredDepends(final ExtensionSet extensionSet)

Adds a set of extensions that this library requires.

Parameters
extensionSet:ExtensionSet

a set of extensions that this library requires.

addConfiguredExtensionback to summary
public void addConfiguredExtension(final ExtensionAdapter extensionAdapter) throws BuildException

Adds an extension that this library implements.

Parameters
extensionAdapter:ExtensionAdapter

an extension that this library implements.

Exceptions
BuildException:
if there is multiple extensions detected in the library.
addConfiguredOptionsback to summary
public void addConfiguredOptions(final ExtensionSet extensionSet)

Adds a set of extensions that this library optionally requires.

Parameters
extensionSet:ExtensionSet

a set of extensions that this library optionally requires.

appendExtensionListback to summary
private void appendExtensionList(final Attributes attributes, final Attributes.Name extensionKey, final String listPrefix, final int size)

Append an attribute such as "Extension-List: lib0 lib1 lib2" using specified prefix and counting up to specified size. Also use specified extensionKey so that can generate list of optional dependencies as well.

Parameters
attributes:Attributes

the attributes to add key-value to

extensionKey:Attributes.Name

the key to use

listPrefix:String

the prefix for all libraries

size:int

the number of libraries to list

appendExtraAttributesback to summary
private void appendExtraAttributes(final Attributes attributes)

Add any extra attributes to the manifest.

Parameters
attributes:Attributes

the manifest section to write attributes to

appendLibraryListback to summary
private void appendLibraryList(final Attributes attributes, final String listPrefix, final List<Extension> extensions) throws BuildException

Append specified extensions to specified attributes. Use the extensionKey to list the extensions, usually "Extension-List:" for required dependencies and "Optional-Extension-List:" for optional dependencies.

Note

"Optional" dependencies are not part of the specification.

Parameters
attributes:Attributes

the attributes to add extensions to

extensions:List<Extension>

the list of extensions

Exceptions
BuildException:
if an error occurs
executeback to summary
public void execute() throws BuildException

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

Execute the task.

Annotations
@Override
Exceptions
BuildException:
if the task fails.
setDestfileback to summary
public void setDestfile(final File destFile)

The location where generated manifest is placed.

Parameters
destFile:File

The location where generated manifest is placed.

toExtensionsback to summary
private List<Extension> toExtensions(final List<ExtensionSet> extensionSets) throws BuildException

Convert a list of ExtensionSet objects to extensions.

Parameters
extensionSets:List<ExtensionSet>

the list of ExtensionSets to add to list

Exceptions
BuildException:
if an error occurs
validateback to summary
private void validate() throws BuildException

Validate the tasks parameters.

Exceptions
BuildException:
if invalid parameters found
writeManifestback to summary
private void writeManifest(final Manifest manifest) throws IOException

Write out manifest to destfile.

Parameters
manifest:Manifest

the manifest

Exceptions
IOException:
if error writing file