puniverse / capsule-maven

Runtime dependency-resolution caplet

Home Page:http://capsule.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Conflicting versions of transitive dependencies on the application classpath

balbusm opened this issue · comments

Capsule-maven puts all transitive dependencies on the classpath even they are same but with different version. On the other hand maven selects only latest one. This leads to the runtime errors (Eg NoSuchMethodError etc).
Please select latest version among the transitive dependencies.

Or at least provide a way to pick one version.

Capsule relies entirely on Aether for dependencies resolution and it already specifies Maven's nearest-wins conflict resolution strategy so theoretically the latest version should be selected already.

Can you share a debug session that shows otherwise and/or (even better) a test case for this behavior?

See https://github.com/puniverse/capsule-maven/blob/master/src/main/java/MavenCapsule.java#L171
You have manifest:
Dependencies: DepA, DepB
It resolves DepA from manifest with all transitive conflicts then resolves DepB from manifest with all transitive conflicts. It doesn't resolve conflicts between list of transitive dependencies from DepA and list of transitive dependencies from DepB, it just combines those two lists.

The resolution mechanism performs lookups and then resolves. lookup ends up calling lookup0 in the Maven caplet which just stores the dependency as unresolved. resolve will end up calling resolve0 in the Maven caplet and the first invocation about an unresolved dependency will call the dependency manager passing all the unresolved dependencies. This means that resolution should theoretically factor versions correctly according to a nearest-wins strategy even across distinct Dependencies entries.

If you can share an example reproducing the issue this will make it easier to identify it and fix it if needed (of course a PR with a fix proposal would be even better).

Thanks!

Setup https://github.com/circlespainter/capsule-maven-13 that should correctly track down this behavior to Aether and got in touch on the mailing list.

Not getting feedback, reported as a bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=490962

The same happens when upgrading Aether to 1.1.0, both test project and issue report updated to reflect that.

Considering https://projects.eclipse.org/projects/technology.aether/reviews/termination-review, also written to the Maven mailing list about it.

@balbusm @gzsombor Could you try capsule-maven 1.0.3-SNAPSHOT that should be available from SonaType snapshots? (it still depends on capsule 1.0.2)

How can I do it? I'm using the com.github.chrischristo:capsule-maven-plugin but I can't specify the version of the capsule-maven

I've just asked about chrisdchristo/capsule-maven-plugin#49 for the future but in the meanwhile I've just published a Capsule 1.0.3-SNAPSHOT (identical to 1.0.2 for now) and a capsule-maven 1.0.3-SNAPSHOT depending on the same Capsule version, so you should be able to use the Maven plugin by specifying capsule.version as 1.0.3-SNAPSHOT.

Hi @gzsombor, @circlespainter you can already set the capsule maven version in the plugin.

The plugin looks for two variables defined in the pom.xml:

<capsule.version>1.0.2</capsule.version>
<capsule.maven.version>1.0.3-SNAPSHOT</capsule.maven.version>

This was done in a recent release, so please check you're using the latest version of the plugin.

@chrischristo Great, thanks!