New issue 298 by neverov....@gmail.com: protobuf jar's manifest should
include OSGi metadata
http://code.google.com/p/protobuf/issues/detail?id=298
What steps will reproduce the problem?
1. build the jar
2. open it and look at META-INF/MANIFEST.MF
What is the expected output? What do you see instead?
- There should be OSGi R4.2 metadata present
What version of the product are you using? On what operating system?
- reproes on all
Please provide any additional information below.
- This is needed in order to be able to install and use protobuf jar inside
OSGi container
Comment #1 on issue 298 by liuj...@google.com: protobuf jar's manifest
should include OSGi metadata
http://code.google.com/p/protobuf/issues/detail?id=298
Hmm, I'm not familiar with OSGi. Would you please provide a patch for this?
Ok. I'll try to look into it later this week (probably over the weekend).
First, I'll try to identify what exactly this metadata should be to make it
work with my project. Then, I'll try to figure out how to make Maven
generate it properly.
Couldn't hold myself from looking into this :) Please find the first
version of the patch attached (sorry if it's not in accepted format - this
is the first time I try to contribute).
There is one concern though. I've noticed that you use "2.4.2-pre" as an
intermediate version number. As far as I know, OSGi spec requires all
components to be separated by dots, so "2.4.2.pre" would be correct.
Without this change, installing such a bundle (jar) into OSGi container
will fail. So, I can see two approaches we can take:
1) Name intermediate versions as OSGi requires (using dots)
2) Create a separate property like "osgi.version"
I would vote for the approach 1), since it avoids duplication.
To my best knowledge, the generated manifest should look like this (feel
free to suggest if something looks wrong):
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: ann
Build-Jdk: 1.6.0_21
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.google.protobuf
Bundle-Version: 2.4.2.pre
Bundle-Name: Protocol Buffer Java API
Bundle-Description: Protocol Buffers are a way of encoding structured
data in an efficient yet extensible format.
Bundle-Vendor: googlecode.com
Bundle-DocURL: http://code.google.com/p/protobuf
Bundle-Category: newtwork, library
Bundle-License: http://www.opensource.org/licenses/bsd-license.php
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: com.google.protobuf;version="2.4.2.pre"
Attachments:
osgi.patch 2.0 KB
My team has been creating and using snapshot bundles in karaf/Felix OSGi
containers for a few months so I don't think it's a hard requirement that
bundles have only 3 dot version #s.
Well, in my project I also use Felix and I believe I got an error
with "2.4.2-pre".
I saw that recommendation in the book called OSGi in Action. Also at
http://www.osgi.org/javadoc/r4v43/org/osgi/framework/Version.html I can see:
"public Version(java.lang.String version)
Created a version identifier from the specified string.
Here is the grammar for version strings.
version ::= major('.'minor('.'micro('.'qualifier)?)?)?
major ::= digit+
minor ::= digit+
micro ::= digit+
qualifier ::= (alpha|digit|'_'|'-')+
digit ::= [0..9]
alpha ::= [a..zA..Z]
There must be no whitespace in version."
So, I guess "2.4.2.-pre" would qualify as well. But IMHO it looks
strange. :)
As a check against what other are doing... we use the following data in
meta-inf
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Protocol Buffers Library
Bundle-SymbolicName: com.google.protobuf
Bundle-Version: 2.4.1
Bundle-Vendor: Google
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: com.google.protobuf
To create an OSGI bundle apply the following changes to the pom.xml:
(Line 14):
<packaging>bundle</packaging>
instead of
<packaging>jar</packaging>
in <build><plugins> add
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>*</Export-Package>
</instructions>
</configuration>
</plugin>
That's about it.