users@jersey.java.net

Re: [Jersey] maven mixes jars?

From: Roger Pack <rogerdpack_at_gmail.com>
Date: Thu, 10 Dec 2009 14:21:55 -0700

> Do you have a dependency on an artifact, let say X, which depends
> on jersey 1.0.2? And besides that you have an explicit dependency on jersey-... 1.1.4.1

I do.

So does maven by default choose the lesser of two required versions or what?

Currently for me...


With a dependency on jersey-test-framework-1.1.4
where "some other dependency" depends on jersey-client 1.0.2

it prefers jersey-core 1.0.2

...
[INFO] +- org.familysearch.digitalarchive:utilities:jar:2.1-SNAPSHOT:compile
"some other dependency" here
[INFO] | +- log4j:log4j:jar:1.2.14:compile
[INFO] | \- com.sun.jersey:jersey-client:jar:1.0.2:compile
[INFO] | \- com.sun.jersey:jersey-core:jar:1.0.2:compile
[INFO] +- org.familysearch.digitalarchive:bitapi:jar:2.1-SNAPSHOT:compile
[INFO] | \- commons-httpclient:commons-httpclient:jar:3.1:compile
[INFO] | \- commons-codec:commons-codec:jar:1.2:compile
[INFO] +- org.easymock:easymock:jar:2.5:test (scope not updated to compile)
[INFO] +- org.familysearch.digitalarchive:perjvm:jar:2.1-SNAPSHOT:compile
[INFO] | \- net.java.dev.jna:jna:jar:3.0.3:compile
[INFO] +- org.familysearch.digitalarchive:api:jar:2.1-SNAPSHOT:compile
[INFO] +- org.familysearch.digitalarchive:clientapis:jar:2.1-SNAPSHOT:compile
[INFO] +- org.familysearch.digitalarchive:clientapis:jar:sources:2.1-SNAPSHOT:provided
[INFO] +- org.familysearch.digitalarchive:DasStorageCellClient:jar:2.1-SNAPSHOT:compile
[INFO] +- com.sun.jersey:jersey-test-framework:jar:1.1.4:test # jersey
test framework only contributes one jar
[INFO] | \- org.glassfish.embedded:glassfish-embedded-all:jar:3.0-Prelude-Embedded-b14:test

If I change the dependency on jersey-test-framework from scope 'test'
to default scope (compile), it stays about the same.

Explicitly adding a dependency to a higher version of jersey-client
[1.1.4] however does update it.

[INFO] +- com.sun.jersey:jersey-client:jar:1.1.4:test (scope not
updated to compile)
[INFO] | \- com.sun.jersey:jersey-core:jar:1.1.4:test
[INFO] +- com.sun.jersey:jersey-test-framework:jar:1.1.4:test
[INFO] | \- org.glassfish.embedded:glassfish-embedded-all:jar:3.0-Prelude-Embedded-b14:test

so it's like...sometimes it wants to prefer a higher transitive
dependency version, sometimes not? Since jersey-test-framework 1.1.4
already has a dependency on client 1.1.4, I wonder why maven seems to
disregard that dependency for a different one...maybe it chooses the
"closest" dependency as most important, for version numbering?




> If so, you could try to get rid of that dependency like follows:

>                <exclusion>
>                    <groupId>com.sun.jersey</groupId>
>                    <artifactId>jersey-client</artifactId>
>                </exclusion>
>                <exclusion>
>                    <groupId>com.sun.jersey</groupId>
>                    <artifactId>jersey-core</artifactId>
>                </exclusion>

Yea that appeared to do it.
Thanks!
-r