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

    Prev Next
    Macro
    Returns the current running bnd version as full major.minor.micro

    Summary

    Returns the version number of the bnd tool currently being used to process the build.

    Syntax

    ${bndversion}
    

    Parameters

    None. This macro takes no parameters.

    Behavior

    Returns the current bnd version as a string in the format major.minor.micro (without the qualifier/build timestamp).

    For example: 7.0.0 or 6.4.0 or 5.3.0

    Examples

    # Display bnd version in bundle manifest
    Bundle-BuildTool: bnd-${bndversion}
    
    # Conditional logic based on bnd version
    -include ${if;${vcompare;${bndversion};7.0.0};modern.bnd;legacy.bnd}
    
    # Document which bnd version was used
    Bundle-Comment: Built with bnd ${bndversion}
    
    # Version-specific features
    -conditionalpackage: ${if;${vcompare;${bndversion};6.4.0};com.new.*;com.legacy.*}
    

    Use Cases

    1. Build Documentation: Record which version of bnd was used to build a bundle
    2. Conditional Configuration: Apply different settings based on bnd version
    3. Feature Detection: Enable features only available in newer bnd versions
    4. Troubleshooting: Help identify build environment for debugging
    5. Version Requirements: Verify minimum bnd version requirements

    Notes

    • The version returned does not include the qualifier (e.g., build timestamp or snapshot indicator)
    • This is the runtime version of bnd, not a property that can be set
    • Useful for ensuring reproducible builds when combined with version checks
    • Can be combined with vcompare for version comparisons

    Related Macros

    • vcompare - Compare version strings
    • version - Format version numbers with masks

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home