bndtools and bnd

repository·master·Indexed 20 days ago

https://github.com/bndtools/bnd

A 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.

Tokens
308K
Snippets
1.2K
Records
1.4K
Agent score
63%

What's inside bndtools

  1. What is the bnd-indexer-maven-plugin?

    master

    The bnd-indexer-maven-plugin is 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:

    1. index goal: 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.
    2. local-index goal: 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., using maven-assembly-plugin).
  2. Overview of Bnd Maven Plugins

    master

    The 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 bndrun files.
    • bnd-resolver-maven-plugin: Resolves bndrun files.
    • bnd-testing-maven-plugin: Runs integration tests defined in bndrun files.
    • bnd-run-maven-plugin: Runs a bndrun file.
    • bnd-reporter-maven-plugin: Generates and exports project reports.
    • bnd-generate-maven-plugin: Generates sources and resources.
  3. Overview of Bnd & Bndtools

    master

    Bnd/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.
  4. Remote debugging with aQute Remote

    master

    The aQute Remote project provides remote debugging support for bnd projects. It allows you to debug bundles and bndrun files 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.launcher in your -runpath and provide a -runremote instruction in your bnd or bndrun file.

  5. Use the bnd command line tool

    master

    The bnd tool 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
  6. Use the bnd-generate-maven-plugin to run bnd generators

    master

    The bnd-generate-maven-plugin is 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 to generate, but also resolves test dependencies and makes them available via -testbuildpath.

    You can configure the plugin using standard Maven <configuration> elements (steps) or via a bndfile using the standard bnd -generate instruction. 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>
  7. What is bnd? (Core Concepts)

    master

    bnd is an OSGi engine used for creating and working with OSGi bundles. It consists of two primary components:

    1. 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.
    2. 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.
  8. What is the ExtensionFacade and why use it?

    master

    The org.bndtools.facade.ExtensionFacade acts 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.

  9. What is a bnd workspace?

    master

    A 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 the cnf directory 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'
  10. What is an OSGi Bundle?

    master

    An 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.

  11. Overview of the Patch Release Process

    master

    The 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 master branch is NOT updated during a patch release.
      • RC1 builds: Uses the previous release version (not the RC range).
      • RC2+ builds: Uses the RC range.
    • Version Metadata: About.java is 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.