• Intro Headers Instructions Macros Commands
Fork me on GitHub
    • Introduction
    • How to install bnd
    • Guided Tour
    • Guided Tour Workspace & Projects
    • Concepts
    • Best practices
    • Build
    • Project Setup
    • Generating JARs
    • Versioning
    • Baselining
    • Service Components
    • Metatype
    • Contracts
    • Bundle Annotations
    • Accessor Properties
    • SPI Annotations
    • Resolving Dependencies
    • Launching
    • Startlevels
    • Testing
    • Testing with Launchpad
    • Packaging Applications
    • JPMS Libraries
    • Wrapping Libraries to OSGi Bundles
    • Generating Documentation
    • Commands
    • For Developers
    • Tips for Windows users
    • Tools bound to bnd
    • Reference
    • Headers
    • Instruction Reference
    • Instruction Index
    • Macro Reference
    • Macro Index
    • Plugins
    • External Plugins
    • Settings
    • Errors
    • Warnings
    • Frequently Asked Questions
  • if ';' STRING ';' STRING ( ';' STRING )?
    Macro

    if         ::= 'if' ';' condition ';' expansion ( ';' expansion )?
    condition  ::= true | false
    false      ::= 'false' | ''
    true       ::= ! false
    expansion  ::= ...
    

    The ${if} macro allows a conditional expansion. The first argument is the condition. the condition is either false (empty or ‘false’) or otherwise true. If the condition is true, the value of the macro is the second argument, the first expansion. Otherwise, if a third argument is specified this is returned. If no third argument is specified, an empty string is returned.

    Examples

    # expands to 'B'
    aorb = ${if;;A;B}
    
    # Display ${foo} if set, otherwise 'Ouch'. See also ${def} 
    whatisfoo = ${if;${foo};${foo};Ouch}
    
    # Include a file conditionally
    -include ${if;${test};test.bnd}
    
    • GitHub