Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Gradle support to include OSGI headers in package #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stromnet
Copy link

@stromnet stromnet commented Mar 4, 2015

This change makes gradle add OSGI headers to the individual Norbert JARs, something which may or may not be useful to others. It should not impact the JARs in any way but adding manifest data.

A non-optimal solution is that all but 'cluster' project manually defines a list of packages to mark for Import. Normally these are resolved by the osgi plugin automatically (the list comes from such an automatic detection), but by default the plugin will add imports declarations such as 'com.linkedin.norbert.cluster;version="(0.6,1.0]"', i.e. an flexible version range, which isn't desired. The manual listing allows us to force 'com.linkedin.norbert.cluster;version="0.6.91"' which is more appropriate for Norbert's different "internal" packages.
An alternative approach is to use the -consumer-policy directive, but that would instead make all other imports, such as log4j, equally strict, something which may not be desired.

A second not-perfect solution is java-network project, which has a manual exports list with a single package. This is to avoid export of "com.linkedin.norbert" caused confusion in the OSGi environment, since that package is also exported from cluster project:

org.osgi.framework.BundleException: Uses constraint violation. Unable to resolve bundle revision com.example.xxxx [349.0] because it is exposed to package 'com.linkedin.norbert' from bundle revisions com.linkedin.norbert.java-network [353.0] and com.linkedin.norbert.cluster [358.0] via two dependency chains.

I tried to use Export-Package: '!com.linkedin.norbert,*' which picked the right packages, but instead left of the version tag for the exported package, effectively giving it version 0.0.0 which makes it unusable.

In addition I didn't succeed with adding OSGi headers to the norbert package (bundled). This seems to be due to a bug in the osgi plugin which fails if a JAR does not have any direct source files.

Example of new META-INF/MANIFEST.MF for java-cluster project (somewhat cleaned up with line-breaks):

Manifest-Version: 1.0
Export-Package: com.linkedin.norbert.javacompat;version="0.6.91";\
 uses:="com.linkedin.norbert.cluster,com.linkedin.norbert.javacompat.cluster,scala,scala.collection.immutable,scala.reflect,scala.runtime",\
 com.linkedin.norbert.javacompat.cluster;version="0.6.91";uses:="com.linkedin.norbert.cluster,com.linkedin.norbert.cluster.memory,scala,scala.collection,scala.reflect,scala.runtime"
Bundle-Vendor: LinkedIn
Bundle-Version: 0.6.91
Tool: Bnd-2.1.0.20130426-122213
Bundle-Name: Norbert Java Cluster
Bnd-LastModified: 1425453196000
Created-By: 1.7.0_55 (Oracle Corporation)
Bundle-ManifestVersion: 2
Bundle-Description: Norbert Java Cluster
Bundle-SymbolicName: com.linkedin.norbert.java-cluster
Import-Package: com.linkedin.norbert.cluster;version="0.6.91",\
 com.linkedin.norbert.cluster.memory;version="0.6.91",\
 scala;version="[2.10,3)",\
 scala.collection;version="[2.10,3)",\
 scala.collection.immutable;version="[2.10,3)",\
 scala.collection.mutable;version="[2.10,3)",\
 scala.reflect;version="[2.10,3)",\
 scala.runtime;version="[2.10,3)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant