• 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
  • -nosubstitution

    Prev Next
    Since 7.2.0
    Setting this to true disables package substitution globally (default is false). That means, that bnd does not calculate Import-Package references for packages exported by the current bundle.

    • Example: -nosubstitution=true

    • Values: true,false

    • Pattern: true|false|TRUE|FALSE



    See Subsitution to learn more about package Substition (a key aspect of OSGi allowing that a package can be both exported and imported).

    Note, that package substitution behaviour is enabled by default in bnd for backward-compatibilty. But recommended to disable for most cases these days via -nosubstitution:true.

    Example

    -nosubstitution:true
    -exportcontents: *
    Import-Package: *
    

    This ensures that no Import-Package is calculated for any package in Export-Package. This is equivalent to Export-Package: *;-noimport:=true or -exportcontents: *;-noimport:=true.

    The advantage is that -nosubstitution:true is a global switch, thus a developer cannot forget to add -noimport:=true in case of a more fine-grained Export-Package declaration with multiple packages.

    Why is it useful?

    It is useful for library authors who never want to have any exported packages in Import-Package. Often, library authors who are just using bnd to generate OSGi metadata in their build scripts (e.g. via maven or gradle plugins) but are otherwise unfamiliar with bnd and OSGi, need a simple way to disable this substitution behavior, because it can lead to surprising resolution results (or failures) after deployment (because other bundles providing the same package are pulled in). This is often undesirable in a pure “library” use-case.

    This instruction helps making bnd / OSGi adoption easier for library projects just wanting to provide OSGi metadata.

Prev Next
Search
    • Home