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

    Prev Next
    Macro
    Remove duplicate elements from one or more lists

    Summary

    The uniq macro combines one or more lists and removes all duplicate elements, preserving insertion order (first occurrence is kept).

    Syntax

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

    Parameters

    • list - One or more semicolon-separated lists to process

    Behavior

    • Combines all provided lists
    • Removes duplicate elements
    • Preserves insertion order (first occurrence kept)
    • Returns comma-separated list of unique elements

    Examples

    Remove duplicates from single list:

    ${uniq;1,2,3,1,2,4}
    # Returns: "1,2,3,4"
    

    Remove duplicates from multiple lists:

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

    Clean package list:

    ${uniq;${exports};${imports}}
    # Returns unique packages
    

    Deduplicate configuration:

    unique.values=${uniq;${list1};${list2};${list3}}
    

    Use Cases

    • Removing duplicate entries from lists
    • Merging lists without duplicates
    • Creating unique sets from multiple sources
    • Cleaning up configuration values
    • Deduplicating package or class lists
    • Set operations on lists

    Notes

    • Preserves insertion order (LinkedHashSet behavior)
    • First occurrence of duplicate is kept
    • Case-sensitive comparison
    • Empty elements are preserved if present
    • See also: ${sort} to also sort the result
    • See also: ${removeall} and ${retainall} for set operations

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home