removeall ';' LIST ';' LIST
Macro
Summary
Remove all elements from the first list that are present in the second list, returning the filtered result.
Syntax
${removeall;<list1>[;<list2>]}
Parameters
- list1: Source list from which elements will be removed
- list2: (Optional) List of elements to remove from list1
Behavior
- If only one list is provided, returns an empty string
- If two lists are provided, returns list1 with all elements from list2 removed
- Performs exact string matching (not pattern matching)
- Order of remaining elements is preserved from list1
Examples
# Remove specific packages
all-packages = com.example.api, com.example.impl, com.example.test
test-packages = com.example.test
production-packages = ${removeall;${all-packages};${test-packages}}
# Returns: com.example.api,com.example.impl
# Remove dependencies
all-deps = foo.jar, bar.jar, baz.jar, test.jar
test-deps = test.jar
runtime-deps = ${removeall;${all-deps};${test-deps}}
# Returns: foo.jar,bar.jar,baz.jar
# Remove multiple items
items = a, b, c, d, e
to-remove = b, d
result = ${removeall;${items};${to-remove}}
# Returns: a,c,e
# No second list - returns empty
${removeall;foo,bar,baz}
# Returns: (empty)
# Remove from build path
full-buildpath = ${buildpath}, ${testpath}
exclude-items = junit, mockito
-buildpath: ${removeall;${full-buildpath};${exclude-items}}
Use Cases
- Package Exclusion: Remove specific packages from export or import lists
- Dependency Management: Exclude certain dependencies from build paths
- List Filtering: Remove known unwanted elements from a list
- Configuration: Filter out test or development-only items from production builds
Notes
- Uses exact string matching, not regular expressions
- For pattern-based filtering, use reject or filterout
- Elements are compared as complete strings
- If an element in list2 doesn’t exist in list1, it’s simply ignored
- Returns empty string if only one argument is provided
Related Macros
- retainall - Keep only elements present in another list (opposite operation)
- reject / filterout - Remove elements matching a regex pattern
- filter / select - Keep elements matching a regex pattern
- uniq - Remove duplicate elements
See test cases in MacroTestsForDocsExamples.java
