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

    Prev Next
    Macro
    Count the total number of elements in one or more lists

    Summary

    The size macro counts and returns the total number of elements across one or more comma-separated lists.

    Syntax

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

    Parameters

    • list - One or more comma-separated lists to count

    Behavior

    • Splits each list on commas
    • Counts all elements across all lists
    • Returns total count as integer
    • Empty elements are counted

    Examples

    Count elements in a list:

    ${size;a,b,c,d}
    # Returns: 4
    

    Count multiple lists:

    ${size;red,green;blue,yellow}
    # Returns: 4
    

    Count packages:

    package.count=${size;${packages}}
    

    Conditional on list size:

    ${if;${size;${exports}};has-exports;no-exports}
    

    Use Cases

    • Counting list elements
    • Validating list sizes
    • Conditional logic based on count
    • Build statistics
    • Dependency counting

    Notes

    • Returns integer count
    • Combines all provided lists
    • Empty strings are counted as elements
    • Maximum 16 lists (implementation limit)
    • See also: ${length} for string length

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home