• 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
  • basename ( ';' FILEPATH ) +

    Prev Next
    Macro
    Extract the filename from one or more file paths

    Summary

    The basename macro extracts the filename (last component) from one or more file paths. It returns only the filenames for files that exist.

    Syntax

    ${basename;<filepath>[;<filepath>...]}
    

    Parameters

    • filepath - One or more file paths (relative to project directory)

    Behavior

    • Resolves each path relative to project directory
    • Filters to include only existing files
    • Returns the filename (last path component) for each
    • Multiple filenames are comma-separated
    • Generates warning if called without arguments

    Examples

    Get single filename:

    ${basename;/path/to/file.txt}
    # Returns: "file.txt"
    

    Multiple files:

    ${basename;src/Main.java;src/Util.java}
    # Returns: "Main.java,Util.java"
    

    With project-relative paths:

    ${basename;${@}}
    # Returns filename of current bundle JAR
    

    Extract from full paths:

    ${basename;${buildpath}}
    # Returns basenames of all buildpath entries
    

    Use Cases

    • Extracting filenames from full paths
    • Getting JAR names from paths
    • Display names in logs
    • Creating filename lists
    • Path manipulation
    • Build output naming

    Notes

    • Only processes existing files
    • Returns filename only, not the directory
    • Path is resolved relative to project base
    • Non-existent files are silently ignored
    • Empty result if no files exist
    • See also: ${dir} for directory path
    • See also: ${stem} for filename without extension

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home