bndtools and bnd
repository·master·Indexed 20 days ago
https://github.com/bndtools/bndA comprehensive toolset for OSGi development featuring bndlib for bundle metadata and dependency management, a versatile command line tool for workspace management and JAR processing, and an Eclipse GUI. The toolset includes plugins like JavaGen for source generation, aQute Remote for remote debugging, and the JUnit Platform Tester for test discovery and execution.
What's inside bndtools
- bndlib is a general-purpose Java library designed for working with OSGi bundles. Its primary purpose is to provide core functionality for OSGi development, such as calculating bundle dependencies and managing bundle metadata.
What is the bnd-indexer-maven-plugin?
masterThe
bnd-indexer-maven-pluginis a bnd-based Maven plugin used to create OSGi repository indexes of bundles. These indexes are suitable for use in OSGi resolution and provisioning systems.The plugin provides two distinct modes of operation:
indexgoal: Creates an index from Maven project dependencies. It uses remote repository URLs to reference dependencies, making it ideal for hosting an OSGi repository system on a remote server. The output includes an XML file and a parallel gzipped version.local-indexgoal: Creates an index from a local folder containing bundles. It uses relative URIs to reference the bundles, which is useful for local testing or when bundling all files into a single release (e.g., usingmaven-assembly-plugin).
Overview of Bnd Maven Plugins
masterThe Bnd Maven Plugins suite provides specialized tools for integrating OSGi development into Maven-based projects. These plugins require at least Maven 3.3.9.
Key plugins include:
- bnd-maven-plugin: The core plugin for generating manifests and metadata for OSGi bundles.
- bnd-indexer-maven-plugin: Generates an OSGi repository index from Maven dependencies, referencing bundle locations in remote repositories.
- bnd-baseline-maven-plugin: Validates semantic versioning compliance (OSGi Alliance standards) by comparing current outputs against previously released versions.
- bnd-export-maven-plugin: Exports
bndrunfiles. - bnd-resolver-maven-plugin: Resolves
bndrunfiles. - bnd-testing-maven-plugin: Runs integration tests defined in
bndrunfiles. - bnd-run-maven-plugin: Runs a
bndrunfile. - bnd-reporter-maven-plugin: Generates and exports project reports.
- bnd-generate-maven-plugin: Generates sources and resources.
Overview of Bnd & Bndtools
masterBnd/Bndtools is a comprehensive toolset for OSGi development. It automates the creation of manifest headers by analyzing class code, verifies settings, manages project dependencies, and provides tools for diffing JARs.
The ecosystem consists of several key components:
- bndlib: The core library containing the fundamental functions.
- Maven Plugins: Integration for Maven-based builds.
- Eclipse Plugin: A p2 repository providing full GUI support for bnd within Eclipse.
- bnd CLI: A command-line utility for various OSGi tasks.
- Gradle Plugins: Support for both bnd workspaces and non-workspace projects.
- Ant: Support for Ant-based builds.
Remote debugging with aQute Remote
masterThe aQute Remote project provides remote debugging support for bnd projects. It allows you to debug bundles and
bndrunfiles on a remote machine running an OSGi framework with an agent installed. The architecture is optimized for small remote machines.To use it, you must include the
biz.aQute.remote.launcherin your-runpathand provide a-runremoteinstruction in yourbndorbndrunfile.Use the bnd command line tool
masterThe
bndtool is a versatile command line interface for OSGi development and workspace management. It supports the full workspace model, allowing you to build, test, and manage projects without external build tools like Gradle or Ant.Key capabilities include:
- Workspace Management:
add,remove,clean,build,compile,run. - Jar Processing:
diff,flatten,extract,source(merge sources),wrap,print. - Dependency Management:
dependencies,graph,maven,repo. - Diagnostics & Reporting:
debug,exportreport,verify,test. - Versioning:
baseline,bump.
To see a list of all available actions, run the command without a name:
bnd- Workspace Management:
Use the bnd-generate-maven-plugin to run bnd generators
masterThe
bnd-generate-maven-pluginis a Maven plugin used to execute bnd generators. It provides a mechanism to run either system commands or external generator plugins.The plugin provides two goals:
generate: Runs generators using the standard-buildpath(all Maven dependencies for the module).generate-test: Similar togenerate, but also resolves test dependencies and makes them available via-testbuildpath.
You can configure the plugin using standard Maven
<configuration>elements (steps) or via abndfileusing the standard bnd-generateinstruction. When using Maven steps, the plugin translates them into a-generate.maven:instruction for bnd.<plugin> <groupId>biz.aQute.bnd</groupId> <artifactId>bnd-generate-maven-plugin</artifactId> <version>${bnd.version}</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin>What is bnd? (Core Concepts)
masterbnd is an OSGi engine used for creating and working with OSGi bundles. It consists of two primary components:
- Manifest generation: Analyzes Java class files and instructions to create JARs with accurate OSGi metadata (
META-INF/MANIFEST.MF). This is used by build tools like Maven, Gradle, and Ant. - Workspace model: An IDE- and build-tool-independent model of a workspace containing projects. This model ensures that development behaves identically whether you are using Eclipse (Bndtools), Maven, Gradle, or the bnd CLI.
- Manifest generation: Analyzes Java class files and instructions to create JARs with accurate OSGi metadata (
What is the ExtensionFacade and why use it?
masterThe
org.bndtools.facade.ExtensionFacadeacts as a bridge between the Eclipse extension registry and OSGi Declarative Services (DS) components.In standard Eclipse development, extensions are often static and tied to the workbench lifecycle, meaning you cannot restart a plugin without restarting the entire Workbench. By using
ExtensionFacade, you can decouple extension implementations from the registry. This allows you to develop Eclipse plugins where the implementation bundles can be dynamically restarted (live coding/testing) without affecting the running Eclipse instance.What is a bnd workspace?
masterA workspace is a directory that provides the structure and context for developing and building OSGi projects. It acts as a cohesive set of bundles that can import and export bundles through repositories.
To be recognized as a workspace, a directory must contain a
cnf/directory with the following structure:cnf/bnd.bnd: Makes bndlib recognize thecnfdirectory as a project.cnf/build.bnd: Contains workspace-wide properties and instructions.cnf/ext/: A directory for plugin setup files.
It is recommended to name your workspace using a shared prefix of the bundle symbolic names of its constituents (e.g.,
com.acme.prime) to improve cohesion and traceability.bnd add workspace com.acme.prime cd com.acme.prime ls # Displays 'cnf'What is an OSGi Bundle?
masterAn OSGi bundle is a JAR file that provides encapsulation by explicitly importing and exporting a set of packages.
Key characteristics:
- Encapsulation: Bundles use package imports and exports to define their boundaries. This allows multiple versions of the same package to coexist in the same environment.
- Resolution: Imports and exports are bound together when bundles are resolved.
- Communication: Once started, a bundle can communicate with the external world by getting or registering services via a service broker.
In the OSGi model, a package acts as a specification (similar to a Java interface), while the bundle provides the implementation.
Overview of the Patch Release Process
masterThe patch release documentation (found in
docs/patch-release-documentation.md) outlines the workflow for MICRO version increases. Key technical details include:- When to use: Guidelines for appropriate patch release scenarios.
- Branching & Builds:
- The
masterbranch is NOT updated during a patch release. - RC1 builds: Uses the previous release version (not the RC range).
- RC2+ builds: Uses the RC range.
- The
- Version Metadata:
About.javais updated with a patch version constant containing 3 components. - Workflow: Covers preparation for the first RC, subsequent RCs (RC2, RC3, etc.), and the final release process.