• 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
  • stem ';' STRING

    Prev Next
    Macro
    Extract the portion of a string before the first dot

    Summary

    The stem macro returns the portion of a string up to (but not including) the first dot character. If no dot is found, returns the entire string.

    Syntax

    ${stem;<string>}
    

    Parameters

    • string - The string to process

    Behavior

    • Finds the first dot (.) character
    • Returns substring before the first dot
    • Returns entire string if no dot is found
    • Only considers the first dot (not subsequent dots)

    Examples

    Extract file basename:

    ${stem;example.txt}
    # Returns: "example"
    

    Get package prefix:

    ${stem;com.example.api}
    # Returns: "com"
    

    Extract version major:

    ${stem;1.2.3}
    # Returns: "1"
    

    No dot present:

    ${stem;filename}
    # Returns: "filename"
    

    Multiple dots:

    ${stem;archive.tar.gz}
    # Returns: "archive" (only first dot)
    

    Use Cases

    • Extracting file basenames without extension
    • Getting first component of qualified names
    • Parsing dotted strings
    • Version number parsing
    • File name manipulation
    • Package name prefixes

    Notes

    • Only removes up to the first dot
    • For removing all extensions, use multiple applications or other methods
    • Returns original string if no dot found
    • Empty string before dot returns empty
    • See also: ${basename} for file name extraction

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home