• 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
    • Reference
    • Headers
    • Instruction Reference
    • Instruction Index
    • Macro Reference
    • Macro Index
    • Plugins
    • External Plugins
    • Settings
    • Errors
    • Warnings
    • Frequently Asked Questions
  • packages
    Analyzer

    The packages macro provides a query function over the contained packages of a bundle. A simple query language is used to query the packages and filter them. For example if you want to export all packages that are annotated with the @org.example.Export annotation:

    -exportcontents: ${packages;ANNOTATED;org.example.Export}
    

    (NB. using the macro inside Export-Package/Private-Package is an error, because they define the content of the bundle. The packages macro can only be used in the final manifest calculation.).

    All pattern matching is based on fully qualified name and uses the globbing model.

    More examples:

    # List all packages in the bundle, irrespective of how they were included
    All-Packages: ${packages}
    
    # List all packages, alternative syntax
    All-Packages: ${packages;ANY}
    
    # Export packages containing the substring 'export'
    -exportcontents: ${packages;NAMED;*export*}
    
    # Export packages that contain a version. Useful when wrapping existing bundles while keeping exports intact
    -exportcontents: ${packages;VERSIONED}
    
    # List of packages that were included in the bundle as conditional packages
    Added: ${packages;CONDITIONAL}
    

    The following table specifies the available query options:

    Query Parameter Description
    ANY Matches any package
    ANNOTATED PATTERN The package must have an annotation that matches the pattern. The annotation must be either CLASS or RUNTIME retained, and placed on the `package-info.class` for the package.
    NAMED PATTERN The package FQN must match the given pattern.
    VERSIONED Packages that are versioned. Usually this means exported packages.
    CONDITIONAL Packages that were included in the bundle as conditional packages. That is, by using -conditionalpackage or Conditional-Package.
    • GitHub