• Intro Headers Instructions Macros Commands
Fork me on GitHub
    • Getting Started
      • Introduction
      • How to install bnd
      • Guided Tour Workspace & Projects
      • bnd / bndlib Features and JAR Wrapping Techniques
      • FAQ - Frequently Asked Questions
    • Concepts and Practices
      • Concepts
      • Background
      • Best practices
    • Build and Development
      • Build
      • 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
      • bnd CLI 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
  • exports

    Prev Next
    Analyzer
    Get the list of packages exported by the current bundle

    Summary

    The exports macro returns a comma-separated list of packages that will be exported by the current bundle. The list can be optionally filtered by providing filter arguments.

    Syntax

    ${exports}
    ${exports;<filter>...}
    

    Parameters

    • filter (optional) - One or more filter patterns to select specific exported packages

    Behavior

    • Returns all packages in the bundle’s Export-Package header
    • Packages are listed in a comma-separated format
    • Optional filter arguments can narrow down the result
    • Available during bundle analysis phase

    Examples

    Get all exported packages:

    exported.pkgs=${exports}
    # Returns: "com.example.api,com.example.impl,com.example.util"
    

    Document exported packages:

    Bundle-Description: Exports ${exports}
    

    Count exported packages:

    export.count=${size;${exports}}
    

    Use in conditional logic:

    ${if;${exports};has-exports;no-exports}
    

    Filter exported packages:

    # Get only API packages (if filter parameters are supported)
    api.exports=${exports;.*\.api}
    

    Use Cases

    • Documenting which packages are exposed by a bundle
    • Validating export configurations
    • Generating bundle documentation
    • Computing bundle metrics (number of exported packages)
    • Conditional logic based on what’s exported
    • Quality checks for proper API exposure

    Notes

    • Only includes packages in the Export-Package manifest header
    • Packages listed here are publicly accessible to other bundles
    • Private packages are not included
    • The list reflects the analyzed/calculated exports, not necessarily what was explicitly declared
    • See also: ${imports} for imported packages

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home