Bnd expects the classpath to be "clean". As such, the moment it finds a
valid package it assumes that's the best one to use.

The simplest thing to do here is to put an exclusion of metrics-core-3.1.2
on whatever dependency pulled it in.

If you do:

mvn dependency:tree

you'll see what top level dependency pulled that artifact into the
classpath.

- Ray



On Wed, Jul 12, 2017 at 10:51 PM, yswai1986 <yswai1...@gmail.com> wrote:

> Plugin version: 3.3.0
> Maven version: 3.3.9
>
> I am wondering how maven-bundle-plugin resolves the version from duplicated
> Export-Packages bundle, the following is from mvn -X debug output and seems
> like the plugin is using the version from the first bundle found.
>
> -----------------------------------------------------------------------
>
> [DEBUG] BND Classpath:
>
> -----------------------------------------------------------------------
>
> -classpath:\
> D:\dev\m3repo\io\dropwizard\metrics\metrics-core\3.1.2\
> metrics-core-3.1.2.jar,\
> D:\dev\m3repo\com\codahale\metrics\metrics-core\3.0.2\
> metrics-core-3.0.2.jar
>
> -----------------------------------------------------------------------
> MANIFEST.MF
> (io\dropwizard\metrics\metrics-core\3.1.2\metrics-core-3.1.2.jar)
>
> Manifest-Version: 1.0
> Bnd-LastModified: 1430020731305
> Build-Jdk: 1.8.0_05
> Built-By: ryantenney
> Bundle-Description: Metrics is a Java library which gives you unparallel
> ed
> insight into what your code does in        production. Metrics provi  des a
> powerful toolkit of ways to measure the behavior of critical
>     components in your production environment.
> Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.html
> Bundle-ManifestVersion: 2
> Bundle-Name: Metrics Core
> Bundle-SymbolicName: io.dropwizard.metrics.core
> Bundle-Version: 3.1.2
> Created-By: Apache Maven Bundle Plugin
> Export-Package:
> com.codahale.metrics;uses:="org.slf4j,javax.management,
> sun.misc";version="3.1.2"
> Implementation-Title: Metrics Core
> Implementation-Vendor-Id: io.dropwizard.metrics
> Implementation-Version: 3.1.2
> Import-Package: javax.management,org.slf4j;version="[1.6.0,2.0.0)",sun.m
> isc;resolution:=optional
> Tool: Bnd-1.50.0
> MANIFEST.MF (com\codahale\metrics\metrics-core\3.0.2\metrics-core-3.0.2.
> jar)
>
> Manifest-Version: 1.0
> Bnd-LastModified: 1392597083041
> Build-Jdk: 1.7.0_51
> Built-By: coda
> Bundle-Description: Metrics is a Java library which gives you unparallel
> ed
> insight into what your code does in     production. Metrics provi  des a
> powerful toolkit of ways to measure the behavior of critical
>     components in your production environment.
> Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.html
> Bundle-ManifestVersion: 2
> Bundle-Name: Metrics Core
> Bundle-SymbolicName: com.codahale.metrics.core
> Bundle-Version: 3.0.2
> Created-By: Apache Maven Bundle Plugin
> Export-Package: com.codahale.metrics;uses:="org.slf4j,javax.management,s
> un.misc";version="3.0.2"
> Implementation-Title: Metrics Core
> Implementation-Vendor-Id: com.codahale.metrics
> Implementation-Version: 3.0.2
> Import-Package: javax.management,org.slf4j;version="[1.6.0,2.0.0)",sun.m
> isc;resolution:=optional
> Tool: Bnd-1.50.0
> And the final output MANIFEST.MF for my bundle:
>
> #-----------------------------------------------------------------------
>
> [DEBUG] Final Manifest:
> #-----------------------------------------------------------------------
> Manifest-Version: 1.0
> Bnd-LastModified: 1499834358907
> Build-Jdk: 1.8.0_111
> Built-By: ys03
> Bundle-Description: MyBundle
> Bundle-DocURL: http://my.bundle
> Bundle-ManifestVersion: 2
> Bundle-Name: MyBundle
> Bundle-SymbolicName: com.foo.bar.myBundle
> Bundle-Vendor: ysw
> Bundle-Version: 1.0.0.11
> Created-By: Apache Maven Bundle Plugin
> Export-Package: com.foo.bar.myBundle;
> Implementation-Version: 1.0.0.11 Build: dfaf45de3d27234d42fcc2841e06ccc8
>  ed530f18 Timestamp: 2017-07-12 12:39:12
> Import-Package:
>  com.fasterxml.jackson.databind;version="[2.3.0,3.0.0)",
>  org.joda.time.format;version="[2.1.0,3.0.0)",
>  com.codahale.metrics;version="[3.1,4)",
>  com.google.common.collect;version="[19.0,20)",
>  org.apache.commons.codec.binary;version="[1.10,2)",
>  org.apache.commons.lang3;version="[3.4,4)",
>  org.slf4j;version="[1.7,2)",
> Tool: Bnd-3.3.0.201609221906
> #-----------------------------------------------------------------------
> The final version for com.codahale.metrics is [3.1,4), I suppose it should
> be [3.0,4), please correct my understanding if I am wrong.
>
> Thanks.
>
>
>
> --
> View this message in context: http://apache-felix.18485.x6.
> nabble.com/maven-bundle-plugin-duplicate-import-
> bundle-with-different-version-tp5021813.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
> For additional commands, e-mail: users-h...@felix.apache.org
>
>


-- 
*Raymond Augé* <http://www.liferay.com/web/raymond.auge/profile>
 (@rotty3000)
Senior Software Architect *Liferay, Inc.* <http://www.liferay.com>
 (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance <http://osgi.org> (@OSGiAlliance)

Reply via email to