The Maven Bnd Repository plugin provides a full interface to the Maven local repository in
~/.m2/repository and remote repositories like Nexus or Artifactory. And it provides of course full access to Maven Central. It implements the standard bnd Repository Plugin and can provide an OSGi Repository for resolving.
To access Maven Central use the following configuration:
-plugin.central = \
To use your local Maven repository (
~/.m2/repository) you can define the following plugin:
-plugin.local = \
To use a remote release repository based on Nexus or Artifactory you can define the following plugin:
-plugin.release = \
releaseUrl=http://localhost:8081/nexus/content/repositories/releases/ ; \
snapshotUrl=http://localhost:8081/nexus/content/repositories/snapshots/ ; \
If you use a remote repository then you must configure the credentials. This is described in -connection-settings. Placing the following XML in
~/.bnd/settings.xml will provide you with the default Nexus credentials:
Notice that the id must match the scheme, the host, and the port if not the default port for the scheme.
The class name of the plugin is
aQute.bnd.repository.maven.provider.MavenBndRepository. It can take the following configuration properties:
|Comma separated list of URLs to the repositories of released artifacts.
|Comma separated list of URLs to the repositories of snapshot artifacts.
|The file path to the local Maven repository.
|If specified, it should use forward slashes. If the directory does not exist, the plugin will attempt to create it.
|The default can be overridden with the
maven.repo.local System property.
|If set to truthy then this repository is read only.
|The name of the repository.
|The path to the index file. The index file is a list of Maven coordinates.
|If set to truthy then this repository will not update the
index when a non-snapshot artifact is released.
|Number of seconds between checks for changes to the
index file. If the value is negative or the workspace is in batch/CI mode, then no polling takes place.
releaseUrl nor a
snapshotUrl are specified then the repository is local only. For finding archives, both URLs are used, first
index file specifies a view on the remote repository, it scopes it. Since we use the bnd repositories to resolve against, it is impossible to resolve against the world. The index file falls under source control, it is stored in the source control management system. This guarantees that at any time the project is checked out it has the same views on its repository. This is paramount to prevent build breackages due to changes in repositories.
The index file contains a list of coordinates. A coordinate specifies an archive in a Maven revison. An archive is a ZIP, POM, JAR, or any other type of file. In Maven, these files are addressed within a revision with an extension and a classifier. The extension indicates the type of the file and the classifier is a modifier that makes the name unique in the project. A revision is the combination of a program and a version, where the program is the combination of groupId and artifactId.
For an archive, the extension has a default of
jar and the classifier is by default not set (either
null or empty). The syntax for the coordinates is therefore:
group ':' artifact ( ':' extension ( ':' classifier )? )? ':' version ( '-SNAPSHOT` )?
Valid coordinates are:
Maven supports a local repository in
~/.m2/repository. All repositories will install through a local repository. The default is the same repository as Maven but this can be overridden with the
local configuration property.
It is possible to define a Maven Bnd Repository without a
snapshotUrl. In that case only access to the local repository is provided. Trying to release remotely will be an error for such a repository.
The -buildrepo instruction can be pointed to such a local repository; it will then store a JAR in the local repository after every build. This can be useful if there are Maven projects that consume the output of a bnd workspace.
In bnd, releasing is done by moving the JARs into a special release repository after they’ve been approved. That is, the location of a JAR defines if it is released, there is no need to reflect the release status in the version.
In Maven, the release status is modeled in the version. To support the staging model, versions can end in
-SNAPSHOT. Snapshots are treated very differently in the release process. The most important difference is that snapshot versions can overwrite previous versions.
In the release cycle, a JAR is
put to release repository. The project of the released JAR is provided as context, this means it can inherit from the project and workspace. This plugin will read the -maven-release instruction from the context. This can result in generating source and javadoc jars. By default, a local only release only installs the actual binary.
To properly release the revision we need to know Maven specific information that is normally specified in the Maven pom. The bnd build can construct a pom using the -pom instruction. This instruction creates a pom in the JAR at
META-INF/group/artifact/pom.xml. This plugin requires such a pom to be present. If it is not present, the -maven-release instruction must provide a PATH to an alternative pom. If no pom can be found then this is aborts the release.
In general, the plugin will first install the JARs and its constituents into the
local revision directory, using the Maven naming rules. If this is successful, it uploads the files to the remote repository using the remote naming rules. It will then update the
maven-metadata to reflect the new release.
In Maven, revisions that end in
-SNAPSHOT are treated special in many places. In bnd, we support this model with the -snapshot and -pom instructions. If a
snapshotUrl is specified, then versions that end in
SNAPSHOT are released to that URL.
The Maven Bnd Repository uses the bnd Http Client. See the -connection-settings instruction for how to set the proxy and authentication information.
The repository view in the IDE will show detailed information when you hover the mouse over the the repository entry, the program entry, or the revision entry.
You can add new entries by:
index file. The repository will be updated immediately
search.maven.org are also supported.