• Intro Headers Instructions Macros Commands
Fork me on GitHub
    • Getting Started
      • How to install bnd
      • Guided Tour
      • Guided Tour Workspace & Projects
      • FAQ - Frequently Asked Questions
    • Concepts and Practices
      • Introduction
      • Concepts
      • Best practices
    • Build and Development
      • Project Setup
      • Generating JARs
      • Versioning
      • Baselining
      • Service Components
      • Metatype
      • Contracts
      • Bundle Annotations
      • Accessor Properties
      • SPI Annotations
    • Dependency and Launching
      • Resolving Dependencies
      • Launching
      • Startlevels
    • Testing
      • Testing
      • Testing with Launchpad
    • Packaging and Distribution
      • Packaging Applications
      • JPMS Libraries
      • Wrapping Libraries to OSGi Bundles
    • Documentation and Tools
      • Generating Documentation
      • Commands
      • For Developers
      • Templates for Workspaces
      • Tips for Windows users
      • Tools bound to bnd
    • Reference Material
      • Reference
      • Headers
      • Instruction Reference
      • Instruction Index
      • Macro Reference
      • Macro Index
      • Plugins
      • External Plugins
    • Configuration and Troubleshooting
      • Settings
      • Errors
      • Warnings
  • packages
    Analyzer

    A list of package names filtered by a query language

    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.
Search
    • Home