[
https://issues.apache.org/jira/browse/CAMEL-26697?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18139813#comment-18139813
]
Serdar Gökay commented on CAMEL-26697:
--------------------------------------
I have a fix for this, and the cause is wider than my description: the
duplicate is not specific to camel-micrometer-prometheus, and there are two
mechanisms.
The dependencies are collected into a Set and the duplicates are removed per
groupId:artifactId as the last step of {{Exporter.resolveDependencies}}. The
three runtime exporters override it, call super first and then add their own
dependencies, so what they add is not deduplicated — and an artifact in the
{{camel:}} notation is a different string from the
{{mvn:org.apache.camel:camel-...:<version>}} that the recorded run holds.
CAMEL-24247 changed the notation of the camel-main metrics and health
dependencies for this reason; that holds only where the base exporter adds the
identical string before the duplicates are removed.
The duplicates are also removed by the coordinates as written, while each
runtime maps the dependencies to its own artifacts afterwards. Two dependencies
with other coordinates become the same artifact there.
Reachable on main (each verified with an export in {{ExportTest}}):
||Export||Named twice in pom.xml||
|{{--runtime=camel-main}},
{{camel.metrics.enabled=true}}|camel-micrometer-prometheus|
|{{--runtime=camel-main --console}}, console options in
application.properties|camel-console, camel-management, camel-health,
camel-platform-http-main, camel-platform-http-jolokia|
|{{--runtime=quarkus --console}}, the same|camel-quarkus-console,
camel-quarkus-management|
|{{--runtime=spring-boot --console}}, the same|camel-console-starter,
camel-management-starter|
|{{--runtime=quarkus --console
--dep=org.apache.camel.quarkus:camel-quarkus-console}}|camel-quarkus-console|
|{{--runtime=spring-boot --console
--dep=org.apache.camel.springboot:camel-console-starter}}|camel-console-starter|
Proposed change, two commits: {{resolveDependencies}} becomes the final step
that removes the duplicates of the dependency strings, with the collection in
an overridable {{doResolveDependencies}}; and the four places that build the
dependencies of the pom remove the duplicates of the mapped artifacts, with one
rule in {{ExportHelper}}. The {{camel:}} notation of CAMEL-24247 is kept.
I will open a pull request with this.
_Claude Code on behalf of etzel-mes_
> camel-jbang - export for camel-main still names camel-micrometer-prometheus
> twice when camel.metrics.enabled is set
> -------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-26697
> URL: https://issues.apache.org/jira/browse/CAMEL-26697
> Project: Camel
> Issue Type: Bug
> Components: camel-jbang
> Affects Versions: 4.23.0
> Reporter: Serdar Gökay
> Assignee: Serdar Gökay
> Priority: Minor
>
> CAMEL-24247 aligned the notation that the camel-main export adds for metrics.
> That covers a project that sets only {{camel.management.metricsEnabled}}.
> With {{camel.metrics.enabled=true}} the exported pom.xml still names
> camel-micrometer-prometheus twice on 4.23.0.
> *Steps to reproduce:*
> {noformat}
> application.properties:
> camel.metrics.enabled=true
> demo.camel.yaml:
> a timer route with a log step
> camel export application.properties demo.camel.yaml --gav=example:demo:1
> --runtime=camel-main --dir=out
> {noformat}
> out/pom.xml has two camel-micrometer-prometheus dependencies. With only
> {{camel.management.metricsEnabled=true}} it has one.
> *What happens:*
> # The run that export uses to detect dependencies loads the component, so
> .camel-jbang/camel-jbang-run.properties records
> {{dependency=mvn:org.apache.camel:camel-micrometer-prometheus:4.23.0}}.
> # {{ExportBaseCommand.resolveDependencies}} removes duplicates by
> groupId:artifactId and keeps that entry.
> # {{ExportCamelMain.resolveDependencies}} then adds
> {{camel:micrometer-prometheus}} because the property is set. The set compares
> strings, so both entries stay.
> {{CamelMainExporter}} on main has the same order.
> *Effect:* Maven 3.9 warns. Maven 3.10.0 fails the build:
> {noformat}
> [ERROR] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must
> be unique: org.apache.camel:camel-micrometer-prometheus:jar -> duplicate
> declaration of version (?)
> {noformat}
> *Proposed change:* remove duplicates once after the runtime-specific
> additions, or make those additions before duplicates are removed. The other
> additions in that method (camel:health, the console artifacts) take the same
> path. We can send a pull request.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)