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

    Prev Next
    Macro
    Rejects a list by matching it against a regular expression

    Summary

    Filter a list to exclude elements that match a regular expression. This macro is an alias for the filterout macro.

    Syntax

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

    Parameters

    • list: Comma-separated list of elements to filter
    • regex: Regular expression pattern to match against

    Behavior

    Returns a new list containing only the elements from the input list that do not match the specified regular expression pattern.

    This macro is functionally identical to filterout.

    Examples

    # Reject items starting with "test"
    packages = com.example.api, com.example.test, com.example.impl
    ${reject;${packages};.*\.test}
    # Returns: com.example.api,com.example.impl
    
    # Exclude test files
    files = Main.java, Test.java, Helper.java, TestHelper.java
    ${reject;${files};.*Test.*}
    # Returns: Main.java,Helper.java
    
    # Exclude internal packages
    all-packages = com.company.api, com.company.internal, com.company.util
    -exportpackage: ${reject;${all-packages};.*\.internal.*}
    # Returns: com.company.api,com.company.util
    
    # Remove snapshot versions
    versions = 1.0.0, 2.0.0-SNAPSHOT, 3.0.0
    ${reject;${versions};.*SNAPSHOT.*}
    # Returns: 1.0.0,3.0.0
    

    Use Cases

    1. Package Exclusion: Exclude internal or test packages from exports
    2. File Filtering: Remove unwanted files from a list
    3. Dependency Filtering: Exclude specific dependencies by pattern
    4. Clean-up: Remove items matching unwanted patterns

    Notes

    • This is an alias for the filterout macro - they behave identically
    • Uses Java regular expression syntax
    • Elements are matched in their entirety (use .* for partial matching)
    • The opposite operation is provided by select or filter

    Related Macros

    • filterout - Identical functionality (primary name)
    • select / filter - Include only elements matching regex
    • removeall - Remove specific elements from a list
    • retainall - Keep only elements present in another list

    TODO Needs review - AI Generated content


    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home