• 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
  • last (';' LIST )*

    Prev Next
    Macro
    Get the last element from one or more lists

    Summary

    The last macro returns the last element from one or more comma-separated lists. If multiple lists are provided, it returns the last element from the combined lists.

    Syntax

    ${last;<list>[;<list>...]}
    

    Parameters

    • list - One or more semicolon-separated lists of values (items within each list are comma-separated)

    Behavior

    • Combines all provided lists into a single list
    • Returns the last element from the combined list
    • Returns an empty string if all lists are empty
    • Preserves the original value (no trimming or transformation)

    Examples

    Get last element from a list:

    ${last;apple,banana,cherry}
    # Returns: "cherry"
    

    Get last from multiple lists:

    ${last;red,green;blue,yellow}
    # Returns: "yellow"
    

    Get last defined value:

    version=${last;1.0.0;${custom.version};${snapshot.version}}
    # Returns last defined version
    

    Use with property lists:

    latest.jar=${last;${buildpath}}
    

    Select last matching file:

    newest=${last;${sort;${lsr;logs;*.log}}}
    

    Use Cases

    • Selecting the final item from a list
    • Getting the most recent value (when lists are ordered)
    • Extracting tail elements for processing
    • Choosing the last available option
    • Implementing last-wins strategies
    • Getting the tail of a sequence

    Notes

    • Returns empty string (not null) for empty lists
    • Does not modify or trim the value
    • Can handle multiple list arguments separated by semicolons
    • See also: ${first} for getting the first element
    • See also: ${get} with negative index (-1) for the same result
    • See also: ${sublist} for extracting multiple elements

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home