• 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
  • -define-contract
    Project

    Define a contract when one cannot be added to the buildpath.

    Used in conjunction with the -contract instruction,-define-contract can be applied in order to define a contract which is not available on the build path (i.e. compile class path).

    The contract specification is exactly the same syntax used in the Provide-Capability header.

    -define-contract:\
      osgi.contract;\
        osgi.contract=JavaServlet;\
        uses:="javax.servlet,javax.servlet.annotation,javax.servlet.descriptor,javax.servlet.http";\
        version:Version="3.0"
    

    Now if the current bundle imports packages declared in the uses directive of the defined contract above, they will be imported without a package version, and a contract requirement will be added exactly as if there had been a contract on the build path.

    Note the -contract instruction defaults to * (all contracts) and so it can be omitted when using the -define-contract instruction.

    Further Reading

    • See -contract and -define-contract instruction for defining contracts in bnd.
    • See also Portable Contract Definitions
Search
    • Home