• 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
  • filterout ';' LIST ';' REGEX

    Prev Next
    Macro
    Filter a list to exclude entries matching a regular expression

    Summary

    The filterout macro filters a list to exclude entries that match a specified regular expression pattern. This is the inverse of ${filter} - entries that match the pattern are removed from the result.

    Syntax

    ${filterout;<list>;<regex>}
    

    Parameters

    • list - A comma or semicolon-separated list of values
    • regex - A Java regular expression pattern to match against

    Behavior

    • Splits the input list into individual entries
    • Compiles the regex pattern
    • Tests each entry against the pattern using full match semantics
    • Removes entries that match the pattern (keeps non-matching ones)
    • Returns the filtered list as a comma-separated string
    • Empty result if all entries match (all excluded)

    Examples

    Exclude test files:

    ${filterout;Main.java,Test.java,TestUtil.java;.*Test.*}
    # Returns: "Main.java"
    

    Exclude snapshot versions:

    ${filterout;1.0.0,2.0.0-SNAPSHOT,3.0.0;.*SNAPSHOT.*}
    # Returns: "1.0.0,3.0.0"
    

    Exclude specific packages:

    ${filterout;com.example.api,com.example.impl,com.example.test;.*\.test}
    # Returns: "com.example.api,com.example.impl"
    

    Exclude by prefix:

    ${filterout;prod-bundle,test-bundle,dev-bundle;test-.*|dev-.*}
    # Returns: "prod-bundle"
    

    Use Cases

    • Removing test files from production builds
    • Excluding snapshot versions from release lists
    • Filtering out unwanted packages or dependencies
    • Cleaning up file lists
    • Removing debug or development artifacts
    • Excluding internal implementation packages

    Notes

    • Uses Java regular expression syntax
    • The pattern must match the entire entry (full match, not substring)
    • Case-sensitive by default (use (?i) for case-insensitive matching)
    • Inverse operation of ${filter} - keeps entries that DON’T match
    • See also: ${reject} which is an alias for ${filterout}
    • See also: ${filter} (or ${select}) for inclusive filtering

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home