• 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
  • findname ';' REGEX ( ';' REPLACEMENT )?

    Prev Next
    Project
    Find bundle resources by filename with optional regex replacement

    Summary

    The findname macro finds resources in the current bundle by matching filenames (not full paths) against a regular expression, with optional replacement to transform the results.

    Syntax

    ${findname[;<regex>[;<replacement>]]}
    

    Parameters

    • regex (optional) - Regular expression to match filenames (default: “.*” matches all)
    • replacement (optional) - Replacement pattern using regex groups (e.g., “$1”)

    Behavior

    • Searches bundle resources by filename only (not full path)
    • Matches filename against regex pattern
    • Optionally applies replacement to matched names
    • Returns comma-separated list of results

    Examples

    Find all resources:

    ${findname}
    

    Find by pattern:

    ${findname;.*\.properties}
    # Returns filenames ending in .properties
    

    Find and transform:

    ${findname;(.*)\.class;$1}
    # Returns class names without .class extension
    

    Extract parts of filenames:

    ${findname;config-(.*)\.xml;$1}
    # Returns: "dev,prod,test" from "config-dev.xml", "config-prod.xml", etc.
    

    Use Cases

    • Resource discovery by name
    • Filename pattern matching
    • Name transformation
    • Bundle content analysis
    • Dynamic resource lists

    Notes

    • Matches filename only, not directory path
    • Uses Java regex syntax
    • See also: ${findpath} for full path matching
    • See also: ${lsr} for file system searches

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home