Java Reference
In-Depth Information
We'll cover version policies in more detail in section A.1.5 and suggest some common
policies.
A.1.4
Variables and macros
Instructions beginning with a lowercase letter are taken as variables (also known as
properties ), which can be used with macros to control or parameterize the bundle con-
tents. Bnd accepts curly, square, round, and angled brackets around macros; this can
be useful if your build system attaches its own meaning to a specific bracket type, such
as Maven and ${} . For consistency, we'll stick to using round brackets throughout this
appendix, because they won't conflict with Maven property interpolation.
The simplest macro is the property placeholder consisting of just a variable name:
$(variable)
Bnd defines other macros of varying complexity that can parse, search, and filter bun-
dle contents—essentially providing its own mini-language to control the build pro-
cess. All bnd macros start with a keyword, followed by one or more parameters
separated by semicolons:
$(keyword;param1;param2)
Let's look at some of the more useful macros:
$(classes;query) —Searches the content of the bundle for classes that match
the given query. You can use this to select all public classes that implement a
certain interface:
$(classes;PUBLIC;IMPLEMENTS;org.foo.Extension)
Or those that use certain annotations somewhere in the class:
$(classes;ANNOTATION;*.Inject)
This macro is useful for scanning component details at build time and recording
the results in the manifest, so you can avoid having to repeatedly scan the bundle
class path at execution time. You can find the full query syntax on the bnd site.
$(env;name) —Evaluates to the value of the named environment variable.
$(filter;list;regex) —Takes a comma-separated list and keeps only the
entries that match the regular expression.
$(filterout;list;regex) —Takes a comma-separated list and removes any
entries that match the regular expression.
$(findname;regex;replacement) —Searches the project class path for
resources whose names match the regular expression. You can provide an
optional replacement string for the resource name, which can also contain the
usual back references to groups in the matched pattern. The following example
macro evaluates to the names of all class resources, but with .java replacing .class :
$(findname;(.*)\.class;$1.java)
$(findpath;regex;replacement) —Similar to findname , but matches against
the complete path rather than just the name.
Search WWH ::




Custom Search