You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Barbara Rosi-Schwartz <Ba...@iggroup.com> on 2011/10/12 13:13:46 UTC

Maven bundle plugin defining wrong version for imported package

Hello everyone.

I am using the Maven bundle plugin to OSGi-ify a set of projects that are non-OSGi. I have two projects, A and B, with B declaring a dependency on A. A is at version 2.10.0-SNAPSHOT and I am declaring a dependency from that version in B's pom.xml.

However, when the Maven bundle plugin creates the MANIFEST.MF files for both projects, it A's manifest declares:

Export-Package: com.acme.projecta.domain; version="2.10.0.SNAPSHOT" (as expected)

But B's manifest declares:
<Import-Package: com.acme.projecta.domain; version="[2.10.0,3.0.0)"

Note how the version range in the Import-Package directive is wrong as it does not include 2.10.0.SNAPSHOT.

What could I possibly be doing wrong? And why sometimes I see a version range being declared in the Import-Package directive and sometimes this is missing altogether?

TIA,
B.

BARBARA ROSI-SCHWARTZ
Senior Developer

IG Group|Cannon Bridge House
25 Dowgate Hill|London|EC4R ZYA

t: +44(0)20 7573 0208 (Direct)
t: +44(0)20 7896 0011 (Switchboard)
w: www.iggroup.com


________________________________
The information contained in this email is strictly confidential and for the use of the addressee only, unless otherwise indicated. If you are not the intended recipient, please do not read, copy, use or disclose to others this message or any attachment. Please also notify the sender by replying to this email or by telephone (+44 (0)20 7896 0011) and then delete the email and any copies of it. Opinions, conclusions (etc) that do not relate to the official business of this company shall be understood as neither given nor endorsed by it. IG Group Holdings plc is a company registered in England and Wales under number 01190902. VAT registration number 761 2978 07. Registered Office: Cannon Bridge House, 25 Dowgate Hill, London EC4R 2YA. Authorised and regulated by the Financial Services Authority. FSA Register number 114059.

RE: Maven bundle plugin defining wrong version for imported package

Posted by Barbara Rosi-Schwartz <Ba...@iggroup.com>.
I think this was a red herring, many apologies, Neil. The SNAPSHOT version is definitely included, I simply misread an error message which stated that the bundle was not found because one of its own dependencies was not found.

BTW, it is fantastic how the plugin transparently handles the "." vs "-" inconsistency in bundle version in the OSGi/Maven views of the world (ex. 2.10.0-SNAPSHOT vs 2.10.0.SNAPSHOT). Very painless and useful!

Thanks also for the explanation about the version range!

-----Original Message-----
From: Neil Bartlett [mailto:njbartlett@gmail.com] 
Sent: 12 October 2011 13:02
To: users@felix.apache.org
Subject: Re: Maven bundle plugin defining wrong version for imported package

 Hi Barbara, 

Could you clarify please? The version range [2.10.0,3.0.0) certainly does include 2.10.0.SNAPSHOT.

Regarding why the version range is sometimes missing. In order to generate the import range, bnd (and therefore maven bundle plugin) needs to know what version of the exported package you were building against. Some of the time this is visible to bnd and it therefore generates a range.

However, you may be building a JAR in isolation, i.e. without its dependencies, so there is no exporter to check. Or you may be building against a plain-JAR dependency rather than an OSGi bundle. Or or you may be building against a bundle that doesn't have versions on its exports.

Bnd does the best it can with the information available to it at build time, but if the information about the exported version is not available then it simply cannot generate an import range. Debatably, bnd could output a warning or error when this is the case.

Regards,
Neil


On Wednesday, 12 October 2011 at 12:13, Barbara Rosi-Schwartz wrote:

> Hello everyone.
> 
> I am using the Maven bundle plugin to OSGi-ify a set of projects that are non-OSGi. I have two projects, A and B, with B declaring a dependency on A. A is at version 2.10.0-SNAPSHOT and I am declaring a dependency from that version in B's pom.xml.
> 
> However, when the Maven bundle plugin creates the MANIFEST.MF files for both projects, it A's manifest declares:
> 
> Export-Package: com.acme.projecta.domain; version="2.10.0.SNAPSHOT" (as expected)
> 
> But B's manifest declares:
> <Import-Package: com.acme.projecta.domain; version="[2.10.0,3.0.0)"
> 
> Note how the version range in the Import-Package directive is wrong as it does not include 2.10.0.SNAPSHOT.
> 
> What could I possibly be doing wrong? And why sometimes I see a version range being declared in the Import-Package directive and sometimes this is missing altogether?
> 
> TIA,
> B.
> 
> BARBARA ROSI-SCHWARTZ
> Senior Developer
> 
> IG Group|Cannon Bridge House
> 25 Dowgate Hill|London|EC4R ZYA
> 
> t: +44(0)20 7573 0208 (Direct)
> t: +44(0)20 7896 0011 (Switchboard)
> w: www.iggroup.com (http://www.iggroup.com)
> 
> 
> ________________________________
> The information contained in this email is strictly confidential and for the use of the addressee only, unless otherwise indicated. If you are not the intended recipient, please do not read, copy, use or disclose to others this message or any attachment. Please also notify the sender by replying to this email or by telephone (+44 (0)20 7896 0011) and then delete the email and any copies of it. Opinions, conclusions (etc) that do not relate to the official business of this company shall be understood as neither given nor endorsed by it. IG Group Holdings plc is a company registered in England and Wales under number 01190902. VAT registration number 761 2978 07. Registered Office: Cannon Bridge House, 25 Dowgate Hill, London EC4R 2YA. Authorised and regulated by the Financial Services Authority. FSA Register number 114059.


Re: Maven bundle plugin defining wrong version for imported package

Posted by Neil Bartlett <nj...@gmail.com>.
 Hi Barbara, 

Could you clarify please? The version range [2.10.0,3.0.0) certainly does include 2.10.0.SNAPSHOT.

Regarding why the version range is sometimes missing. In order to generate the import range, bnd (and therefore maven bundle plugin) needs to know what version of the exported package you were building against. Some of the time this is visible to bnd and it therefore generates a range.

However, you may be building a JAR in isolation, i.e. without its dependencies, so there is no exporter to check. Or you may be building against a plain-JAR dependency rather than an OSGi bundle. Or or you may be building against a bundle that doesn't have versions on its exports.

Bnd does the best it can with the information available to it at build time, but if the information about the exported version is not available then it simply cannot generate an import range. Debatably, bnd could output a warning or error when this is the case.

Regards,
Neil


On Wednesday, 12 October 2011 at 12:13, Barbara Rosi-Schwartz wrote:

> Hello everyone.
> 
> I am using the Maven bundle plugin to OSGi-ify a set of projects that are non-OSGi. I have two projects, A and B, with B declaring a dependency on A. A is at version 2.10.0-SNAPSHOT and I am declaring a dependency from that version in B's pom.xml.
> 
> However, when the Maven bundle plugin creates the MANIFEST.MF files for both projects, it A's manifest declares:
> 
> Export-Package: com.acme.projecta.domain; version="2.10.0.SNAPSHOT" (as expected)
> 
> But B's manifest declares:
> <Import-Package: com.acme.projecta.domain; version="[2.10.0,3.0.0)"
> 
> Note how the version range in the Import-Package directive is wrong as it does not include 2.10.0.SNAPSHOT.
> 
> What could I possibly be doing wrong? And why sometimes I see a version range being declared in the Import-Package directive and sometimes this is missing altogether?
> 
> TIA,
> B.
> 
> BARBARA ROSI-SCHWARTZ
> Senior Developer
> 
> IG Group|Cannon Bridge House
> 25 Dowgate Hill|London|EC4R ZYA
> 
> t: +44(0)20 7573 0208 (Direct)
> t: +44(0)20 7896 0011 (Switchboard)
> w: www.iggroup.com (http://www.iggroup.com)
> 
> 
> ________________________________
> The information contained in this email is strictly confidential and for the use of the addressee only, unless otherwise indicated. If you are not the intended recipient, please do not read, copy, use or disclose to others this message or any attachment. Please also notify the sender by replying to this email or by telephone (+44 (0)20 7896 0011) and then delete the email and any copies of it. Opinions, conclusions (etc) that do not relate to the official business of this company shall be understood as neither given nor endorsed by it. IG Group Holdings plc is a company registered in England and Wales under number 01190902. VAT registration number 761 2978 07. Registered Office: Cannon Bridge House, 25 Dowgate Hill, London EC4R 2YA. Authorised and regulated by the Financial Services Authority. FSA Register number 114059.