• Intro Headers Instructions Macros Commands
  • Fork me on GitHub
    • Introduction
    • How to install bnd
    • Guided Tour
    • Guided Tour Workspace & Projects
    • Concepts
    • Best practices
    • Build
    • Project Setup
    • Generating JARs
    • Versioning
    • Baselining
    • Service Components
    • Metatype
    • Contracts
    • Bundle Annotations
    • Accessor Properties
    • SPI Annotations
    • Resolving Dependencies
    • Launching
    • Startlevels
    • Testing
    • Testing with Launchpad
    • Packaging Applications
    • JPMS Libraries
    • Wrapping Libraries to OSGi Bundles
    • Generating Documentation
    • Commands
    • For Developers
    • Tips for Windows users
    • Tools bound to bnd
    • Headers
    • Instruction Reference
    • Instruction Index
    • Macro Reference
    • Macro Index
    • Plugins
    • External Plugins
    • Settings
    • Errors
    • Warnings
    • Frequently Asked Questions
  • findproviders ';' namespace ( ';' FILTER )?

    The findproviders macro gives access to the resources in the Workspace repositories, including the projects itself. Its semantics match the OSGi Repository.findProviders() method.

    It was added to support the use case of including a set of plugins in a resolve to create an executable. Since it is impossible to add a requirement that will add all matching resources, the findproviders macro can be used to find these resources and then turn them into initial requirements. However, this macro will likely find many other use cases since it is quite versatile.

    findproviders ::= namespace ( ';' FILTER )?
    namespace     ::= ... OSGi namespace
    

    If no filter is given then all resources that have a capability in the given namespace are returned.

    The result is in PARAMETERS format, to common format in bnd and OSGi. In this case the key will be the Bundle Symbolic Name and the attributes will at least contain the Bundle version. For example:

    ${findproviders;osgi.service}
    

    This finds all resources that have an osgi.service capability. This could return something like:

    com.h2database;version=1.4.198,
    org.apache.aries.async;version=1.0.1,
    org.apache.felix.configadmin;version=1.9.12,
    org.apache.felix.coordinator;version=1.0.2,
    org.apache.felix.eventadmin;version=1.5.0,
    ...
    

    This PARAMETERS format is structured because it has attributes; that makes it harder to use with all kind of other macros. The ${template} macro was intended to help out. This macro takes the name of macro and then treats the contents as a PARAMETERS. It then applies a template to each clause in the PARAMETERS. For example:

    my.plugins = ${findproviders;osgi.service;(objectClass=com.example.my.Plugin)}
    -runrequires.plugins = ${template;my.plugins;osgi.identity;filter:='(osgi.identity=${@})'}
    

    This would turn the previous example into:

    -runrequires.plugins = \
        osgi.identity;filter:='(osgi.identity=com.h2database)',
        osgi.identity;filter:='(osgi.identity=org.apache.aries.async)',
        ..
    

    Maven support

    The usage of the findproviders macro as depicted above also works when used in the context of one of the Maven plugins.

    • GitHub