You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Andy Jefferson <li...@datanucleus.org> on 2011/05/24 17:13:26 UTC

Felix Maven2 "bundle" plugin : problem with version ranges

Hi,

I tried experimenting with the bundle plugin to generate a MANIFEST.MF (rather 
than using manually generated ones that we currently use). I'm getting 
problems with the ImportPackage declarations of version ranges.

The project is minimal, and pom.xml includes

    <packaging>bundle</packaging>
    <repositories>
        <repository>
            <id>DataNucleus_M2</id>
            <name>DataNucleus Maven2 Repository</name>
            <url>http://www.datanucleus.org/downloads/maven2</url>
        </repository>
        <repository>
             <id>DataNucleus_M2-nightly</id>
             <name>DataNucleus Maven2 Nightly Repository</name>
             <url>http://www.datanucleus.org/downloads/maven2-nightly</url>
        </repository>
    </repositories>
    
    <dependencies>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-core</artifactId>
            <version>[2.9, )</version>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-api-jdo</artifactId>
            <version>[2.9, )</version>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-rdbms</artifactId>
            <version>[2.9, )</version>
        </dependency>
        <dependency>
            <groupId>javax.jdo</groupId>
            <artifactId>jdo-api</artifactId>
            <version>[3.0, )</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.3.4</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.artifactId};singleton:=true</Bundle-SymbolicName>
                        <Export-Package>org.datanucleus.test.*</Export-Package>
                        <Import-Package>*</Import-Package>
                    </instructions>
                </configuration>
            </plugin>


and the generated MANIFEST.MF has
Import-Package: javax.jdo;version="[3.1,4)",javax.jdo.annotations;vers
 ion="[3.1,4)",org.datanucleus.util

javax.jdo has versions 3.0, 3.1-SNAPSHOT-20110223, 3-1-SNAPSHOT-20110319 in 
the specified repositories, and I selected inclusive versions from 3.0. So how 
does it get 3.1.4+?????!


Also, how would I get it to generate a Require-Bundle for the org.datanucleus 
dependencies in my dependencies section?


TIA
-- 
Andy
DataNucleus (http://www.datanucleus.org)

Re: Felix Maven2 "bundle" plugin : problem with version ranges

Posted by Andy Jefferson <li...@datanucleus.org>.
> Peter Kriens replied
> The problem is that if you compile against 3.1 then you likely dependn on 3.1. 
> The code you compile against influences the byte codes of your generated class 
> files, availability of methods etc. So imho you can never get an import range 
> that starts with a version that is lower to what you compiled with. Anyway, in 
> your POM you specified a range, which part of the range gets picked should then 
> not be of your concern. If you want to be in control, specify the exact version.
Not in this case. I compile against 3.1, yes. But I can run against 3.0, aka 
backwards compatibility. So in the same way someone can import the 3.0 bundle 
of javax.jdo and run with that in an OSGi environment, not just using what I 
compiled against.


> Obviously you can override it with bnd's Import-Package statement, the 
> automatic stuff is only done when no version is specified on an import.
Yes, but then I have to specify things in two places that the version range is 
XXX - once for Maven and once for the OSGi MANIFEST.MF, and I was hoping your 
nice plugin had made my job much simpler ;-) No problem, i'll continue doing 
it manually, but I'd suggest that it ought to be an aim of the plugin (whether 
in this version, or for the future) to provide for such situations, otherwise 
it is only of use for very simple cases.

Thanks.

Regards
-- 
Andy

Re: Felix Maven2 "bundle" plugin : problem with version ranges

Posted by Peter Kriens <pe...@aqute.biz>.
The problem is that if you compile against 3.1 then you likely dependn on 3.1. The code you compile against influences the byte codes of your generated class files, availability of methods etc. So imho you can never get an import range that starts with a version that is lower to what you compiled with. Anyway, in your POM you specified a range, which part of the range gets picked should then not be of your concern. If you want to be in control, specify the exact version.

Obviously you can override it with bnd's Import-Package statement, the automatic stuff is only done when no version is specified on an import.

Kind regards,

	Peter Kriens





On 25 mei 2011, at 07:49, Andy Jefferson wrote:

>> I think the disconnect is that the maven-bundle-plugin (as I understand it)
>> generates the Import-Package version number by letting Bnd analyze the
>> *jar* in question and not by looking at the version numbers you specify in
>> the pom.  So maven sees [3.0, 3.9) or [3.0,) and grabs whatever version of
>> jdo it deems appropriate, which in this case is one of the 3.1 snapshots. 
>> Then that jar gets handed to Bnd to do its thing.  Since Bnd only sees the
>> jar (and not your maven dependency information), all it sees is the
>> version of the package exported by the jar, which is (something like) 
>> 3.1.0.SNAPSHOT. This version gets truncated down to [3.1.0,4) or [3.1,4)
>> based on how Bnd is configured.
>> 
>> Does that make sense?
> 
> Well it's a reasonable explanation of what the plugin is doing. It's still 
> wrong though, since if the user asks for a range then they want a range in 
> OSGi too. I'll raise it in JIRA.
> 
> Thanks for your time.
> 
> Regards
> -- 
> Andy
> DataNucleus (http://www.datanucleus.org)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Felix Maven2 "bundle" plugin : problem with version ranges

Posted by Andy Jefferson <li...@datanucleus.org>.
> I think the disconnect is that the maven-bundle-plugin (as I understand it)
> generates the Import-Package version number by letting Bnd analyze the
>  *jar* in question and not by looking at the version numbers you specify in
>  the pom.  So maven sees [3.0, 3.9) or [3.0,) and grabs whatever version of
>  jdo it deems appropriate, which in this case is one of the 3.1 snapshots. 
>  Then that jar gets handed to Bnd to do its thing.  Since Bnd only sees the
>  jar (and not your maven dependency information), all it sees is the
>  version of the package exported by the jar, which is (something like) 
>  3.1.0.SNAPSHOT. This version gets truncated down to [3.1.0,4) or [3.1,4)
>  based on how Bnd is configured.
> 
> Does that make sense?

Well it's a reasonable explanation of what the plugin is doing. It's still 
wrong though, since if the user asks for a range then they want a range in 
OSGi too. I'll raise it in JIRA.

Thanks for your time.

Regards
-- 
Andy
DataNucleus (http://www.datanucleus.org)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Felix Maven2 "bundle" plugin : problem with version ranges

Posted by Mike Smoot <mi...@gmail.com>.
I think the disconnect is that the maven-bundle-plugin (as I understand it)
generates the Import-Package version number by letting Bnd analyze the *jar*
in question and not by looking at the version numbers you specify in the
pom.  So maven sees [3.0, 3.9) or [3.0,) and grabs whatever version of jdo
it deems appropriate, which in this case is one of the 3.1 snapshots.  Then
that jar gets handed to Bnd to do its thing.  Since Bnd only sees the jar
(and not your maven dependency information), all it sees is the version of
the package exported by the jar, which is (something like)  3.1.0.SNAPSHOT.
  This version gets truncated down to [3.1.0,4) or [3.1,4) based on how Bnd
is configured.

Does that make sense?



Mike

On Tue, May 24, 2011 at 12:20 PM, Andy Jefferson <li...@datanucleus.org>wrote:

> If I simply specify "pom.xml" with "javax.jdo" dependency as
> <version>3.0.0</version>
> then the plugin gets the OSGi version as [3.0.0, 4.0)
>
> but if I specify a Maven version range then it gets the OSGi version wrong
> (IMHO)
>
> M2 [3.0, 3.9)  -> [3.1.0, 4.0)
> M2 [3.0, ) -> [3.1.0, 4.0)
>
>
>
> --
> Andy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
____________________________________________________________
Michael Smoot, Ph.D.
UCSD Department of Medicine
tel: 858-822-4756

Re: Felix Maven2 "bundle" plugin : problem with version ranges

Posted by Andy Jefferson <li...@datanucleus.org>.
If I simply specify "pom.xml" with "javax.jdo" dependency as
<version>3.0.0</version>
then the plugin gets the OSGi version as [3.0.0, 4.0)

but if I specify a Maven version range then it gets the OSGi version wrong 
(IMHO)

M2 [3.0, 3.9)  -> [3.1.0, 4.0)
M2 [3.0, ) -> [3.1.0, 4.0)



-- 
Andy

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Felix Maven2 "bundle" plugin : problem with version ranges

Posted by Andy Jefferson <li...@datanucleus.org>.
On Tuesday 24 May 2011 19:54:07 Mike Smoot wrote:
> There's a comma you're missing.  The version range is from 3.1 up to, but
> not including version 4.  This is based on the export version supplied by
> the library in question (which is presumably one of the 3.1 snapshots
> because you specified a range in the dependency) and the semantic
>  versioning standard that Bnd uses.  You can read about why the version is
>  3.1 here: http://www.aqute.biz/Bnd/Versioning.  If you want the import
>  package range to be [3.0,4), then I think you just need to specify your
>  jdo version as 3.0 in your dependency

Thx for your reply.

In Maven I want 3.0 and above, and that's just what I specified (for Maven).
As per
http://maven.apache.org/plugins/maven-enforcer-plugin/rules/versionRanges.html
The bundle plugin is responsible for converting that into MANIFEST.MF format 
no? and it comes up with  "[3.1, 4)".

Yes, I mistyped the last part of my question (omitting the comma, thx), but I 
did state exactly what the plugin is generating.

Import-Package: javax.jdo;version="[3.1,4)", ...

I don't see how a Maven2 version spec of [3.0, ) translates to meaning [3.1, 
4.0) in OSGi. I can live with the upper of 4 but it is missing off the 3.0.0 
version present in Maven2 repos. 
"javax.jdo" v3.0.0 exports 3.0.0 of javax.jdo packages (in its MANIFEST).
"javax.jdo" v3.1-SNAPSHOT-xxx export v 3.1.0 of javax.jdo packages.


Regards
-- 
Andy

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Felix Maven2 "bundle" plugin : problem with version ranges

Posted by Mike Smoot <mi...@gmail.com>.
There's a comma you're missing.  The version range is from 3.1 up to, but
not including version 4.  This is based on the export version supplied by
the library in question (which is presumably one of the 3.1 snapshots
because you specified a range in the dependency) and the semantic versioning
standard that Bnd uses.  You can read about why the version is 3.1 here:
http://www.aqute.biz/Bnd/Versioning.  If you want the import package range
to be [3.0,4), then I think you just need to specify your jdo version as 3.0
in your dependencyk rather than as a range.  It gets confusing detangling
the maven versions and how they are used from the OSGi versions and how they
are used.

Dunno about the Require-Bundle question.


Mike

On Tue, May 24, 2011 at 8:13 AM, Andy Jefferson <li...@datanucleus.org>wrote:

> Hi,
>
> I tried experimenting with the bundle plugin to generate a MANIFEST.MF
> (rather
> than using manually generated ones that we currently use). I'm getting
> problems with the ImportPackage declarations of version ranges.
>
> The project is minimal, and pom.xml includes
>
>    <packaging>bundle</packaging>
>    <repositories>
>        <repository>
>            <id>DataNucleus_M2</id>
>            <name>DataNucleus Maven2 Repository</name>
>            <url>http://www.datanucleus.org/downloads/maven2</url>
>        </repository>
>        <repository>
>             <id>DataNucleus_M2-nightly</id>
>             <name>DataNucleus Maven2 Nightly Repository</name>
>             <url>http://www.datanucleus.org/downloads/maven2-nightly</url>
>        </repository>
>    </repositories>
>
>    <dependencies>
>        <dependency>
>            <groupId>org.datanucleus</groupId>
>            <artifactId>datanucleus-core</artifactId>
>            <version>[2.9, )</version>
>        </dependency>
>        <dependency>
>            <groupId>org.datanucleus</groupId>
>            <artifactId>datanucleus-api-jdo</artifactId>
>            <version>[2.9, )</version>
>        </dependency>
>        <dependency>
>            <groupId>org.datanucleus</groupId>
>            <artifactId>datanucleus-rdbms</artifactId>
>            <version>[2.9, )</version>
>        </dependency>
>        <dependency>
>            <groupId>javax.jdo</groupId>
>            <artifactId>jdo-api</artifactId>
>            <version>[3.0, )</version>
>            <scope>provided</scope>
>        </dependency>
>    </dependencies>
>            <plugin>
>                <groupId>org.apache.felix</groupId>
>                <artifactId>maven-bundle-plugin</artifactId>
>                <version>2.3.4</version>
>                <extensions>true</extensions>
>                <configuration>
>                    <instructions>
>
>  <Bundle-SymbolicName>${project.artifactId};singleton:=true</Bundle-SymbolicName>
>
>  <Export-Package>org.datanucleus.test.*</Export-Package>
>                        <Import-Package>*</Import-Package>
>                    </instructions>
>                </configuration>
>            </plugin>
>
>
> and the generated MANIFEST.MF has
> Import-Package: javax.jdo;version="[3.1,4)",javax.jdo.annotations;vers
>  ion="[3.1,4)",org.datanucleus.util
>
> javax.jdo has versions 3.0, 3.1-SNAPSHOT-20110223, 3-1-SNAPSHOT-20110319 in
> the specified repositories, and I selected inclusive versions from 3.0. So
> how
> does it get 3.1.4+?????!
>
>
> Also, how would I get it to generate a Require-Bundle for the
> org.datanucleus
> dependencies in my dependencies section?
>
>
> TIA
> --
> Andy
> DataNucleus (http://www.datanucleus.org)
>



-- 
____________________________________________________________
Michael Smoot, Ph.D.
UCSD Department of Medicine
tel: 858-822-4756