1
votes

I'm currently developing an Eclipse plugin. Its building and deploying is supported by Tycho and Maven. Now I would like to add Googles Guava v. 14 to the project as a dependency. On the Tychos wiki page I have found that it can only resolve dependencies if they are OSGi bundles. I was not able to find this version of Guava as an OSGi bundle. So what is the common workaround for this situation?

  • Check out interested revision from Guava repository, add MANIFEST, bundle it and add to the projects path, seams to me like a very dirty workaround — I need to maintain this bundle by myself, I can't simply upgrade a bundle, I need to commit a binary in the VCS for CI.
  • Doing the same but storing the bundle in some maven repository — Maintaining a repository with source code actually duplicates existing, upgrading not so simple to.

It seams to me like very-very hard to import existing java code in OSGi projects.

3

3 Answers

2
votes

Guava is 100% OSGi ... and a few more characters to reach 30

1
votes

Don't try to convert a library to an OSGi bundle yourself:

  • Either, it is simple to turn the library into an OSGi bundle, e.g. if a correct manifest can be generated using one of the BND based tools.

    In this case, the provider of the library should do that directly. For a Maven build, they'd just need to add the bundle goal of the maven-bundle-plugin.

  • Or, it is hard to turn the library into an OSGi bundle, e.g. because the library uses class loading concepts that don't work in OSGi.

    In this case, the library would need to be changed, and this can only be done by the provider of the library.

0
votes

Guava is an OSGI add this to your pom.xml in your dependencies section

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>18.0</version> <!--Replace with version you want to use-->
    </dependency>

Make sure you list Maven Central repository in your list of repositories

    <repository>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <name>Central Repository</name>
        <url>https://repo.maven.apache.org/maven2</url>
    </repository>