• 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
  • global ';' KEY ( ';' DEFAULT )?

    Prev Next
    Workspace
    Access user settings from the ~/.bnd/settings.json file

    Summary

    The global macro provides access to user-specific settings stored in the ~/.bnd/settings.json file. This allows builds to use machine-specific configuration like credentials, API tokens, or user preferences without storing them in project files.

    Syntax

    ${global;<key>[;<default>]}
    

    Parameters

    • key - The setting name to retrieve from settings.json
    • default (optional) - Default value to return if the setting is not found

    Behavior

    • Reads from the user’s ~/.bnd/settings.json file in their home directory
    • Returns the value for the specified key
    • Returns the default value if provided and key is not found
    • Returns null if key is not found and no default is provided
    • Special keys:
      • key.public - Returns the user’s public key as hex string
      • key.private - Returns the user’s private key as hex string

    Examples

    Access a custom setting:

    maven.user=${global;maven.username}
    

    Use with default value:

    api.key=${global;example.api.key;default-key}
    

    Access credentials:

    -connection: ${global;nexus.url}; \
                 uid=${global;nexus.username}; \
                 pwd=${global;nexus.password}
    

    Get public key:

    signing.key=${global;key.public}
    

    Conditional on global setting:

    ${if;${global;enable.feature};enabled;disabled}
    

    Use Cases

    • Storing user-specific credentials outside project files
    • Machine-specific configuration (different per developer)
    • API tokens and authentication information
    • User preferences for build behavior
    • Private repository credentials
    • Signing keys and certificates
    • Environment-specific URLs and endpoints

    Notes

    • Settings are stored in JSON format in ~/.bnd/settings.json
    • The settings file is per-user, not per-project
    • Keeps sensitive information out of version control
    • Returns null (not empty string) when key is missing and no default
    • The special key.public and key.private keys access cryptographic keys
    • Settings can be edited directly in the JSON file
    • Useful for CI/CD where different machines need different configurations

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home