How to Get OSGi R7 Bundles Into Central Repository

209 views
Skip to first unread message

robert.p...@leidos.com

unread,
Mar 2, 2018, 9:10:50 AM3/2/18
to bndtools-users
Hi,

I'm building my own bundles based on what I learned in the R7 Postgres example.  In the R7 example, my Central repository somehow has the R7 versions of osgi.annotation, osgi.cmpn, and osgi.core, plus many more.  These bundles are in my Central Repository without being in my central.xml.  How can I do this in my new bundles?  What OSGi magic in the R7 example pulled these bundles in?  I've read the Repositories page on the enRoute site, and I've looked in my Window > Preferences > Bndtools, but I can't find it.

Thanks!

robert.p...@leidos.com

unread,
Mar 2, 2018, 9:12:26 AM3/2/18
to bndtools-users
Also, my new bundles are in a new Bndtools workspace without Maven.

Tim Ward

unread,
Mar 2, 2018, 10:21:24 AM3/2/18
to bndtool...@googlegroups.com
Hi Bob,

So the important thing to remember is that the Maven dependency model and the Bndtools workspace Gradle dependency model are completely different.

In Maven your dependencies are specified in your pom file, and are found in the repositories that are also configured in your pom file. Often the repositories and versions of dependencies are managed in a single place (your parent pom) and inherited. Maven has an implicit repository (Maven Central) which is where you find most things, but some dependencies (for example the OSGi R7 release candidates) live in other repositories.

In a Bnd workspace build “repositories" are defined in the cnf project - there is no such thing as an implicit repository and your dependencies can only come from repositories that have been configured. There are many different types of repository:
  • Local repositories such as a file repository or an indexed repository. These are folders which physically contain the jars that you’re going to use as dependencies. You can drag more bundles into these repositories as you need them
  • Local/Remote OSGi repositories (such as a Fixed Indexed Repository). These repositories point at an OSGi standard index file and provide access to the bundles listed in the repository index
  • Maven-style repositories - there are two main types
    • Maven Repositories (for example “Central” in the https://github.com/bndtools/workspace template). These retrieve dependencies from a Maven repository (usually a nexus instance) but only those dependencies listed in the index file (for example “Central” has a central.maven file). This index file lists the GAV coordinates of the dependencies that should be in the bnd repository
    • POM repositories - These repositories point at a POM file, and include all of the dependencies (including transitive dependencies) listed in the POM.


So, to come back to your problem. The reason that you could access the R7 APIs, implementations, and other dependencies in the Maven-based example is that the parent pom had been configured to provide access to those things using the OSGi snapshot repository and the enRoute indexes. The Bndtools workspace template that you have used knows nothing of these things (having been set up for OSGi R6) and provides access to a limited set of bundles via its configured repositories. This repository configuration lives in the cnf folder (you can see build.bnd in there) not in the Eclipse preferences as these repositories are used in CI as well as the IDE.

If you want to access R7 API bundles in your Bndtools workspace then you will need to set up additional repositories containing those bundles. That may take the form of an additional Maven Repository, one or more POM repositories, or a local repository where you put the bundles.

Best Regards,

Tim

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

robert.p...@leidos.com

unread,
Mar 2, 2018, 10:21:41 AM3/2/18
to bndtools-users
I think I found the dependencies in enroute-central.xml.  Is it safe to copy this file from my R7 example workspace to my new Bndtools workspace?


On Friday, March 2, 2018 at 9:10:50 AM UTC-5, robert.p...@leidos.com wrote:

Tim Ward

unread,
Mar 2, 2018, 10:26:31 AM3/2/18
to bndtool...@googlegroups.com
Not really,

To add a repository to your build you need to configure it in your cnf folder’s build.bnd file (or a related file depending on how your workspace is configured). Just copying an XML file won’t do much.

Regards,

Tim

robert.p...@leidos.com

unread,
Mar 2, 2018, 10:44:39 AM3/2/18
to bndtools-users
Hi Tim,

I'm using the Bndtools plugin version 4.0 snapshot.  Does it support R6 or R7?

I see these dependencies in the example's /indexes/osgi-api/pom.xml.  So, I put them in my new workspace's central.xml.  But, my package-info.java still doesn't compile because of "@org.osgi.annotation.bundle.Export".

        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.core</artifactId>
            <version>7.0.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.cmpn</artifactId>
            <version>7.0.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.annotation</artifactId>
            <version>7.0.0-SNAPSHOT</version>
        </dependency>

Should this have worked?

Thanks,
Bob

On Friday, March 2, 2018 at 9:10:50 AM UTC-5, robert.p...@leidos.com wrote:

Tim Ward

unread,
Mar 2, 2018, 10:51:43 AM3/2/18
to bndtool...@googlegroups.com
Bndtools 4.0.0-DEV (which contains bnd 4.0.0-DEV) supports a number of new features from OSGi R7, for example processing the new Bundle annotations, but it is just an IDE plugin, not a workspace or a build. Whether you end up using R6 or R7 to build against is entirely determined by the repositories you configure in your workspace.

In answer to your question about central.xml - I would not expect this to work as the dependencies that you have listed are not present in Maven Central (Maven Central does not allow snapshots) . The dependencies are present in the OSGi Snapshots section of the Sonatype OSS repository, and should be visible if you reference them from there.

Best Regards,

Tim

robert.p...@leidos.com

unread,
Mar 2, 2018, 12:37:12 PM3/2/18
to bndtools-users
Hi Tim,

I found the Sonatype OSS Snapshots repository here:  https://oss.sonatype.org/content/repositories/snapshots/.  Is this the right one?

I'm trying to put it into my /cnf/build.bnd file.  I created an Indexed repository, but it didn't work.  Which type should I use in the wizard (file, HTTP connector, indexed, JPA, locally indexed)?

Thanks,
Bob

On Friday, March 2, 2018 at 9:10:50 AM UTC-5, robert.p...@leidos.com wrote:

Tim Ward

unread,
Mar 2, 2018, 2:50:28 PM3/2/18
to bndtool...@googlegroups.com
Hi Bob,

That is the right repository, and it’s a Nexus repository. That means you will need to use one of the Maven type repositories (for example the same type of repository as central). 

Tim

Sent from my iPhone
--

robert.p...@leidos.com

unread,
Mar 5, 2018, 9:02:16 AM3/5/18
to bndtools-users
Hi Tim,

I have added the plugin, below, to my build.bnd file.  But, my package-info.java files don't compile.  Is something wrong with this plugin?

-plugin.10.Snapshots:  \
    aQute.bnd.repository.maven.pom.provider.BndPomRepository; \
        releaseUrls=https://repo1.maven.org/maven2/; \
        pom=${build}/snapshots.xml; \
        name=Snapshots; \
        location=${build}/cache/enroute-snapshots.xml

Here is my snapshots.xml file:

<groupId>local</groupId>
<artifactId>Snapshots</artifactId>
<version>0.0.0</version>

<packaging>pom</packaging>

<dependencies>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.core</artifactId>
            <version>7.0.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.cmpn</artifactId>
            <version>7.0.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.annotation</artifactId>
            <version>7.0.0-SNAPSHOT</version>
        </dependency>
</dependencies>

Thanks,
Bob

On Friday, March 2, 2018 at 9:10:50 AM UTC-5, robert.p...@leidos.com wrote:

robert.p...@leidos.com

unread,
Mar 5, 2018, 9:15:31 AM3/5/18
to bndtools-users
I got it to compile my package-info.java files, but now the "Build" tab in my project's bnd.bnd file has this error:

Service-Component entry '*' is not a FQN.  Bnd no longer supports the deprecated Bnd DS annotations.


On Friday, March 2, 2018 at 9:10:50 AM UTC-5, robert.p...@leidos.com wrote:

BJ Hargrave

unread,
Mar 5, 2018, 9:53:08 AM3/5/18
to bndtool...@googlegroups.com
You should not have a Service-Component header in your bnd file.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
BJ

robert.p...@leidos.com

unread,
Mar 5, 2018, 10:25:44 AM3/5/18
to bndtools-users
I don't have a Service-Component header in my bnd file.  Here it is:

Bundle-Version: 1.0.0.${tstamp}
Bundle-Description: My DAO API project

Export-Package:  \
my.package

Require-Capability: \
compile-only

-includeresource: {readme.md}

-buildpath: \
osgi.enroute.base.api;version=2.1,\
osgi.annotation;version=7.0

-testpath: \
osgi.enroute.junit.wrapper;version=4.12, \
osgi.enroute.hamcrest.wrapper;version=1.3

On Friday, March 2, 2018 at 9:10:50 AM UTC-5, robert.p...@leidos.com wrote:

BJ Hargrave

unread,
Mar 5, 2018, 10:51:31 AM3/5/18
to bndtool...@googlegroups.com
What about cnf/build.bnd or any bnd file in cnf/ext? Grep is your friend here.
--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
BJ

robert.p...@leidos.com

unread,
Mar 5, 2018, 1:06:59 PM3/5/18
to bndtools-users
Yep.  I commented it out in cnf/build.bnd and now it works.  Thanks!


On Friday, March 2, 2018 at 9:10:50 AM UTC-5, robert.p...@leidos.com wrote:
Reply all
Reply to author
Forward
0 new messages