• 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
  • glob ';' GLOBEXP

    Prev Next
    Macro
    Convert a glob pattern to a regular expression

    Summary

    The glob macro converts a glob pattern (shell-style wildcard pattern) into a Java regular expression. This is useful when you need regex patterns but want to write simpler glob syntax.

    Syntax

    ${glob;<glob-pattern>}
    

    Parameters

    • glob-pattern - A glob pattern using wildcard syntax (e.g., *.jar, com/example/**/*.class)

    Behavior

    • Converts glob wildcards to regex equivalents:
      • * → matches any characters except path separator
      • ** → matches any characters including path separators
      • ? → matches any single character
      • [abc] → matches any character in the set
      • {a,b,c} → matches any of the alternatives
    • Supports negation with ! prefix
    • Returns a valid Java regular expression string

    Examples

    Convert simple wildcard:

    ${glob;*.jar}
    # Returns regex matching JAR files
    

    Match with path:

    ${glob;com/example/**/*.class}
    # Returns regex for any .class file under com/example/
    

    Use in filter:

    ${filter;${packages};${glob;com.example.*}}
    # Filter packages matching glob pattern
    

    Negated pattern:

    ${glob;!*.test.jar}
    # Returns negative lookahead regex excluding test JARs
    

    Multiple alternatives:

    ${glob;*.{jar,war,ear}}
    # Matches files with .jar, .war, or .ear extensions
    

    Use Cases

    • Converting user-friendly glob patterns to regex
    • Pattern matching in file filtering
    • Configuration patterns that are easier to write as globs
    • Combining glob syntax with regex-based macros
    • Path matching in resource selection
    • Building dynamic filter patterns

    Notes

    • Glob syntax is simpler and more intuitive than regex for basic patterns
    • The ! prefix creates a negative lookahead pattern
    • * does not cross directory boundaries (use ** for that)
    • The returned value is a regex pattern string, not a compiled Pattern object
    • Glob patterns are case-sensitive by default
    • See also: Instructions and filters in bnd often accept glob patterns directly

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home