Frank Lee
Frank Lee

Reputation: 2748

How to build Felix compatible OSGi bundles with Tycho?

I'm trying to build OSGi bundles for use in both Equinox and Felix. Some of my bundles use javax.* packages, for example javax.net.

The JRE supplies that package, no problem there, it works in both frameworks.

Felix requires me to import that package in the MANIFEST.MF:

Import-Package: javax.net

It makes sense, as only java.* packages should be included implicitly. For some reason Equinox is fine either way, it seems to magically find them anyway.

My problem comes when I build with Tycho. The Tycho build fails when I add that Import-Package:

Resolution errors:
   Bundle com.dexels.mybundle - Missing Constraint: Import-Package: javax.net; version="0.0.0"

So in a nutshell: Without import package Felix fails, with it Tycho fails.

I'm aware of this kind of workaround using a system bundle fragment, but really hope that I won't need to resort to this.

Is there a way to add these packages to Tycho?

Can I use something like org.osgi.framework.system.packages.extra?

Thanks, Frank

Upvotes: 4

Views: 718

Answers (1)

jsievers
jsievers

Reputation: 1853

If you specify the Bundle-RequiredExecutionEnvironment header with a JDK that provides this package, tycho should be able to resolve the package.

you may run into https://bugs.eclipse.org/bugs/show_bug.cgi?id=371565

If so, you will need tycho 0.15.0, see http://wiki.eclipse.org/Tycho/Release_Notes/0.15

Upvotes: 3

Related Questions