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

    Prev Next
    Macro
    Calculate the sum of numeric values in one or more lists

    Summary

    The sum macro calculates the sum of all numeric values provided in one or more lists. Each element is parsed as a double-precision floating-point number.

    Syntax

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

    Parameters

    • list - One or more semicolon-separated lists of numeric values

    Behavior

    • Parses all elements as double-precision numbers
    • Calculates the sum of all values
    • Returns the total as a string
    • Throws exception if any value is not numeric

    Examples

    Sum a simple list:

    ${sum;1,2,3,4,5}
    # Returns: "15"
    

    Sum multiple lists:

    ${sum;10,20;30,40}
    # Returns: "100"
    

    Sum decimal values:

    ${sum;1.5,2.5,3.5}
    # Returns: "7.5"
    

    Calculate total from properties:

    total=${sum;${value1};${value2};${value3}}
    

    Use Cases

    • Calculating totals and aggregates
    • Summing metric values
    • Computing combined sizes or counts
    • Mathematical calculations in builds
    • Aggregating numeric configuration

    Notes

    • All values must be numeric
    • Returns double-precision result
    • See also: ${average} for mean calculation
    • See also: ${max} and ${min} for extremes

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home