speechkey
speechkey

Reputation: 625

Using non-OSGi packages in Eclipse Plugins

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?

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

Upvotes: 1

Views: 344

Answers (3)

kloklo90
kloklo90

Reputation: 81

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>

Upvotes: 0

oberlies
oberlies

Reputation: 11723

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.

Upvotes: 1

Peter Kriens
Peter Kriens

Reputation: 15372

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

Upvotes: 2

Related Questions