Claus Ibsen created CAMEL-24483:
-----------------------------------
Summary: camel-jbang export: explicit --dep version is ignored for
auto-detected dependencies
Key: CAMEL-24483
URL: https://issues.apache.org/jira/browse/CAMEL-24483
Project: Camel
Issue Type: Bug
Components: camel-jbang
Reporter: Claus Ibsen
h3. Problem
When running {{camel export}} on a project containing a bean that Camel
auto-detects a dependency for (e.g. a Postgres {{BasicDataSource}} whose
{{driverClassName}} is {{org.postgresql.Driver}}), Camel adds
{{org.postgresql:postgresql}} to the generated {{pom.xml}} using the version
inferred from the {{camel-dependencies}} BOM.
Passing {{--dep=org.postgresql:postgresql:<version>}} to override that version
has no effect - the generated POM keeps the auto-detected version and the
user's explicit version is silently dropped.
h3. Root cause
In {{ExportBaseCommand.resolveDependencies()}} the dependencies are collected
into a {{TreeSet}} and then de-duplicated by {{groupId:artifactId}} only,
keeping the *first* entry in the set's sorted order (ignoring the version).
Auto-detected dependencies are recorded with an {{mvn:}} prefix (written by
{{Run.RunDownloadListener.onDownloadDependency}}) while a plain
{{--dep=group:artifact:version}} is not, so the {{mvn:}}-prefixed auto-detected
entry always sorts first and wins. There is no precedence given to a
user-supplied {{--dep}}.
Using {{--dep=mvn:org.postgresql:postgresql:<version>}} does not reliably help
either, since the dedup then falls back to lexicographic comparison of the
version strings.
h3. Fix
Make an explicit {{--dep}} version (one that carries a version) take precedence
over an auto-detected dependency for the same {{groupId:artifactId}} during
de-duplication.
h3. Workaround
Manually edit the generated {{pom.xml}} and set the desired driver version.
----
_Reported via the Camel community (Marat Gubaidullin). Analysis and fix drafted
by Claude Code on behalf of Claus Ibsen (davsclaus)._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)