Class BndAnalyzer
- All Implemented Interfaces:
Generator, Renamable, ResourceProvider
A Generator that computes OSGi metadata in response to requests for
ManifestAttributes.
This implementation uses the bndlib library from the
bnd project to analyze bundle
contents and compute manifest attributes.
When invoked, the analyzer first obtains resources of type ClassTree
supplied to the project (typically by a JavaCompiler). These class
trees are treated as the content of the bundle.
It then obtains resources of type LibraryJarFile from the project's
dependencies with intents Consume, Reveal and Expose (the same
intents as used by the JavaCompiler when assembling the compilation
classpath). These library resources are registered as bundle
dependencies.
The collected class tree and library resources are analyzed by bndlib
to produce the manifest attributes requested.
Contrary to most ResourceProviders, the BndAnalyzer needs project
specific informations (supplied as instructions). This can be handled
in multiple ways. One approach is to add the BndAnalyzer with the
instructions in the project’s constructor rather than in
RootProject.prepareProject(Project). Alternatively, put project-specific
instructions in a bnd.bnd file in the project's directory, then
register the analyzer in RootProject.prepareProject(Project) and add the
instructions via instructions(Path), where Path refers to the
bnd.bnd file.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoProvide(ResourceRequest<T> requested) Invoked byResourceProviderSpi.provide(ResourceRequest)after checking if the invocation is allowed.instruction(String key, String value) Add the instruction specified by key and value.instructions(Path bndFile) Add the instructions from the given bnd (properties) file.instructions(Map<String, String> instructions) Add the given instructions for the analyzer.Methods inherited from class AbstractBndGenerator
applyInstructionsMethods inherited from class AbstractGenerator
cleanup, name, newResource, project, toStringMethods inherited from class AbstractProvider
context, name, of, rename, vavrStream
-
Constructor Details
-
BndAnalyzer
Initializes a new osgi analyzer.- Parameters:
project- the project
-
-
Method Details
-
instruction
Add the instruction specified by key and value.- Overrides:
instructionin classAbstractBndGenerator- Parameters:
key- the keyvalue- the value- Returns:
- the bnd analyzer
-
instructions
Add the given instructions for the analyzer.- Overrides:
instructionsin classAbstractBndGenerator- Parameters:
instructions- the instructions- Returns:
- the bnd analyzer
-
instructions
Add the instructions from the given bnd (properties) file.- Overrides:
instructionsin classAbstractBndGenerator- Parameters:
bndFile- the bnd file- Returns:
- the bnd analyzer
-
doProvide
Description copied from class:AbstractProviderInvoked byResourceProviderSpi.provide(ResourceRequest)after checking if the invocation is allowed.- Specified by:
doProvidein classAbstractProvider- Type Parameters:
T- the generic type- Parameters:
requested- the requested- Returns:
- the stream
-