The plugin for Maven Central in OSGi enRoute points to [jpm4j]. Since this repository is largely filled with Maven Central, let’s override it with the Maven Bnd Repository using the same . The definition is as follows in the file ./cnf/ext/enroute.bnd
:
-plugin.4.Central: \
\
aQute.bnd.deployer.repository.wrapper.Plugin; \
location = "${build}/cache/wrapper"; \
reindex = true, \
\
aQute.bnd.jpm.Repository; \
includeStaged = true; \
name = Central; \
location = ~/.bnd/shacache; \
index = ${build}/central.json
This repository definition defines 2 plugins. The wrapper and the jpm repository. The jpm repository communicates with the central server. The function of the Wrapper Plugin is to provide OSGi metadata for the downloaded archives.
We only need 1 wrapper for all possible Maven Bnd Repository plugins. Make sure you only define the wrapper once.
The ext
bnd files are read before the ./cnf/build.bnd
is read, we can therefore reliably override the configuration, just use the same property name: -plugin.4.Central
. Therefore we override the configuration as follows in ./cnf/build.bnd
:
-plugin.4.Central = \
aQute.bnd.repository.maven.provider.MavenBndRepository; \
releaseUrl = https://repo.maven.apache.org/maven2/; \
name = Central
After saving the build.bnd
file, the Repositories view in Bndtools is updated, the Central
repository is now a Maven Repository that points to Maven Central. (It replaced the JPM repository with the same name.) You can hover your mouse over the repository name to see the details.
By default, this repository is empty, nothing, nada. So why is that? Well, One of the goals of bnd is to have repeatable builds over very long times. If you checkout your project ten years from now then it should build the same files as it does today. Unfortunately, if your repositories change then the build results can potentially change. For this reason, we maintain the view of what we want to see from Maven Central in a file.
This file should be under source control management so that anytime in the future when a previous revision is checked out, it will see exactly the same contents of the repository.
The most basic way to extend the scope is editing the corresponding file. Since we did not specify this file (the configuration property is index
), we used the default which is the name of the ./cnf/
+ repository name in lower case + .mvn
. In this case, ./cnf/central.mvn
. The format of the file is a maven coordinate per line. For example:
commons-math:commons-math:1.2
dnsjava:dnsjava:2.1.1
org.apache.felix:org.apache.felix.framework:bundle:5.4.0
Obviously manually editing this file is not such an pleasant thought. There are therefore a number of ways you edit the file in the Repositories View of Bndtools.
You can:
Once you have a revision in the Repositories view, you can manipulate it by calling up a context menu.
All changes that are made are immediately reflected in the file. Changes in the file are reflected in the Repositories view.
In the Maven Bnd Repository, each entry (repository, program, and revision) have a context menu and provide additional information when you hover over them.
Revisions and programs are identified by their corresponding Bundle Symbolic Name if they are bundles. If they’re not bundles, then the Maven coordinate is displayed.