Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Bundle

...

Plugin

...

for

...

Maven

...

This

...

plugin

...

for

...

Maven

...

2

...

is

...

based

...

on

...

the

...

BND

...

tool

...

from

...

Peter

...

Kriens.

...

The

...

way

...

BND

...

works

...

is

...

by

...

treating

...

your

...

project

...

as

...

a

...

big

...

collection

...

of

...

classes

...

(e.g.,

...

project

...

code,

...

dependencies,

...

and

...

the

...

class

...

path).

...

The

...

way

...

you

...

create

...

a

...

bundle

...

with

...

BND

...

is

...

to

...

tell

...

it

...

the

...

content

...

of

...

the

...

bundle's

...

JAR

...

file

...

as

...

a

...

subset

...

of

...

the

...

available

...

classes.

...

This

...

plugin

...

wraps

...

BND

...

to

...

make

...

it

...

work

...

specifically

...

with

...

the

...

Maven

...

2

...

project

...

structure

...

and

...

to

...

provide

...

it

...

with

...

reasonable

...

default

...

behavior

...

for

...

Maven

...

2

...

projects.

...

Anchor
simple-example
simple-example

...

Simple

...

Example

...

Rather

...

than

...

going

...

straight

...

to

...

a

...

detailed

...

list

...

of

...

plugin

...

features,

...

we

...

will

...

first

...

look

...

at

...

a

...

simple

...

example

...

of

...

how

...

to

...

use

...

the

...

plugin

...

to

...

give

...

an

...

immediate

...

flavor.

...

A

...

detailed

...

"

...

how

...

to

...

"

...

will

...

follow.

...

Assume

...

that

...

we

...

have

...

a

...

simple

...

bundle

...

project

...

that

...

has

...

a

...

pubic

...

API

...

package

...

an

...

several

...

implementation

...

packages,

...

such

...

as:

{
No Format
}
org.foo.myproject.api
org.foo.myproject.impl1
org.foo.myproject.impl2
...
{noformat}

If

...

we

...

also

...

assume

...

that

...

we

...

have

...

a

...

bundle

...

activator

...

in

...

one

...

of

...

the

...

implementation

...

packages,

...

then

...

<plugins>

...

section

...

of

...

the

...

POM

...

file

...

would

...

look

...

like

...

this:

{
No Format
}
...
<plugins>
  <plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>bundle-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
      <instructions>
        <Export-Package>org.foo.myproject.api</Export-Package>
        <Private-Package>org.foo.myproject.*</Private-Package>
        <Bundle-Activator>org.foo.myproject.impl1.Activator</Bundle-Activator>
      </instructions>
    </configuration>
  </plugin>
<plugins>
...
{noformat}

The {{

The <Export-Package>

...

and

...

<Private-Package>

...

instructions

...

tell

...

the

...

plugin

...

about

...

the

...

contents

...

of

...

the

...

bundle

...

JAR

...

file.

...

The

...

<Export-Package>

...

instruction

...

tells

...

the

...

plugin

...

which

...

of

...

the

...

available

...

packages

...

to

...

include

...

into

...

the

...

bundle

...

and

...

to

...

export,

...

while

...

the

...

<Private-Package>

...

instruction

...

indicates

...

which

...

of

...

the

...

available

...

packages

...

to

...

include

...

into

...

the

...

bundle

...

but

...

not

...

export.

...

If

...

the

...

two

...

sets

...

overlap,

...

as

...

they

...

do

...

in

...

the

...

case,

...

then

...

the

...

export

...

takes

...

precedence.

...

Since

...

we

...

did

...

not

...

specify

...

any

...

values

...

for

...

any

...

other

...

bundle

...

manifest

...

headers,

...

they

...

will

...

assume

...

default

...

values

...

which

...

are

...

described

...

below

...

.

...

One

...

specific

...

behavior

...

to

...

highlight

...

is

...

that

...

the

...

plugin

...

generates

...

the

...

Import-Package

...

bundle

...

manifest

...

header

...

based

...

on

...

the

...

specified

...

contents

...

of

...

the

...

bundle,

...

which

...

means

...

that

...

you

...

generally

...

do

...

not

...

ever

...

need

...

to

...

specify

...

it.

...

That's

...

it.

...

Features

The BND library underlying the plugin defines instructions to direct its functionality. For this Maven plugin, these instructions are issues in the plugin configuration section of the POM file, as was illustrated [above|#simple-example}.

...

BND

...

recognizes

...

three

...

types

...

of

...

instructions:

...

  1. Manifest

...

  1. headers

...

  1. -

...

  1. Any

...

  1. instruction

...

  1. that

...

  1. starts

...

  1. with

...

  1. a

...

  1. capital

...

  1. letter

...

  1. will

...

  1. appear

...

  1. in

...

  1. the

...

  1. resulting

...

  1. bundle's

...

  1. manifest

...

  1. file;

...

  1. the

...

  1. value

...

  1. will

...

  1. either

...

  1. be

...

  1. copied,

...

  1. augmented,

...

  1. or

...

  1. generated

...

  1. by

...

  1. BND

...

  1. depending

...

  1. on

...

  1. the

...

  1. instruction.

...

  1. Variables - Any instruction starting with a lowercase letter is assumed to be a variable in the form of a name-value pair, such as version=3.0

...

  1. ,

...

  1. that

...

  1. can

...

  1. be

...

  1. used

...

  1. with

...

  1. property

...

  1. substitution,

...

  1. but

...

  1. are

...

  1. not

...

  1. copied

...

  1. to

...

  1. the

...

  1. manifest.

...

  1. Directives - Any instruction starting with a '-'

...

  1. character

...

  1. is

...

  1. considered

...

  1. to

...

  1. be

...

  1. a

...

  1. directive

...

  1. that

...

  1. informs

...

  1. BND

...

  1. to

...

  1. perform

...

  1. some

...

  1. special

...

  1. processing

...

  1. and

...

  1. are

...

  1. not

...

  1. copied

...

  1. to

...

  1. the

...

  1. manifest.

...

The

...

remainder

...

of

...

this

...

section

...

covers

...

the

...

most

...

important

...

aspects

...

of

...

BND's

...

instructions;

...

for

...

complete

...

details

...

refer

...

to

...

the

...

BND

...

documentation

...

.

Anchor
default-behavior
default-behavior

Default Behavior

To use this plugin, very little information is required by BND. As part of the Maven integration, the plugin tries to set reasonable defaults for various instructions. For example:

  • Bundle symbolic name is set to ${groupId}.${artifactId

...

  • }

...

  • .

...

properties.put(Analyzer.BUNDLE_SYMBOLICNAME,

...

bsn);

...


properties.put(Analyzer.IMPORT_PACKAGE,

...

"*");

...


properties.put(Analyzer.EXPORT_PACKAGE,

...

bsn

...

+

...

".*");

...


String

...

version

...

=

...

project.getVersion().replace('-',

...

'.');

...


properties.put(Analyzer.BUNDLE_VERSION,

...

version);

...


header(properties,

...

Analyzer.BUNDLE_DESCRIPTION,

...

project
.getDescription());

...


header(properties,

...

Analyzer.BUNDLE_LICENSE,

...

printLicenses(project.getLicenses()));

...


header(properties,

...

Analyzer.BUNDLE_NAME,

...

project.getName());

...


header(properties,

...

Analyzer.BUNDLE_VENDOR,

...

project
.getOrganization());

...


header(properties,

...

Analyzer.INCLUDE_RESOURCE,

...

"src/main/resources");

...

Instructions

Anchor
how-to
how-to

...

Detailed

...

"How

...

To"

...